/
file-location.ts
86 lines (77 loc) · 2.38 KB
/
file-location.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Construct } from 'constructs';
import { CfnProject } from './codebuild.generated';
import { IProject } from './project';
/**
* The type returned from `IFileSystemLocation#bind`.
*/
export interface FileSystemConfig {
/**
* File system location wrapper property.
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-projectfilesystemlocation.html
*/
readonly location: CfnProject.ProjectFileSystemLocationProperty;
}
/**
* The interface of a CodeBuild FileSystemLocation.
* Implemented by `EfsFileSystemLocation`.
*/
export interface IFileSystemLocation {
/**
* Called by the project when a file system is added so it can perform
* binding operations on this file system location.
*/
bind(scope: Construct, project: IProject): FileSystemConfig;
}
/**
* FileSystemLocation provider definition for a CodeBuild Project.
*/
export class FileSystemLocation {
/**
* EFS file system provider.
* @param props the EFS File System location property.
*/
public static efs(props: EfsFileSystemLocationProps): IFileSystemLocation {
return new EfsFileSystemLocation(props);
}
}
/**
* EfsFileSystemLocation definition for a CodeBuild project.
*/
class EfsFileSystemLocation implements IFileSystemLocation {
constructor(private readonly props: EfsFileSystemLocationProps) {}
public bind(_scope: Construct, _project: IProject): FileSystemConfig {
return {
location: {
identifier: this.props.identifier,
location: this.props.location,
mountOptions: this.props.mountOptions,
mountPoint: this.props.mountPoint,
type: 'EFS',
},
};
}
}
/**
* Construction properties for `EfsFileSystemLocation`.
*/
export interface EfsFileSystemLocationProps {
/**
* The name used to access a file system created by Amazon EFS.
*/
readonly identifier: string;
/**
* A string that specifies the location of the file system, like Amazon EFS.
*
* This value looks like `fs-abcd1234.efs.us-west-2.amazonaws.com:/my-efs-mount-directory`.
*/
readonly location: string;
/**
* The mount options for a file system such as Amazon EFS.
* @default 'nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2'.
*/
readonly mountOptions?: string;
/**
* The location in the container where you mount the file system.
*/
readonly mountPoint: string;
}