ECSBuilder¶
Bases: AbstractAWSResourceBuilder['EfsBuilder', EfsConfig]
AWS CDK builder for comprehensive EFS (Elastic File System) infrastructure deployment.
Orchestrates the creation of scalable, fully managed NFS file systems with configurable performance characteristics, throughput modes, encryption settings, and fine-grained access control through EFS access points. Supports cross-account parameter sharing for multi-environment deployments and organizational security standards.
The builder creates: - EFS file system with configurable performance and throughput modes - KMS encryption for data at rest when enabled - Security group integration for network access control - Multiple access points with POSIX user/group enforcement - SSM parameter storage for cross-stack references - Cross-account resource sharing for DevOps environments - IAM policies for service integration (DataSync, ECS, etc.)
Source code in mare_aws_common_lib/builders/efs_builder.py
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
Attributes¶
_resource_type = AWSResourceType.EFS
class-attribute
instance-attribute
¶
Functions¶
_control_consistency()
¶
Validate builder configuration and internal state consistency.
Performs comprehensive pre-build validation to ensure all required configurations are present and the builder state is consistent for successful EFS infrastructure deployment.
Raises:
| Type | Description |
|---|---|
ValueError
|
If EFS base name is not set - required for resource naming |
ValidationError
|
If EfsConfig validation fails during configuration setup |
Source code in mare_aws_common_lib/builders/efs_builder.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
_create_access_points(scope, file_system)
¶
Create EFS access points with POSIX user and permission enforcement.
Creates configured access points that provide application-specific entry points into the EFS file system with predefined user/group identities, directory paths, and file system permissions for enhanced security.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope for access point creation |
required |
file_system
|
FileSystem
|
EFS file system to attach access points to |
required |
Returns:
| Type | Description |
|---|---|
List[AccessPoint]
|
List of configured EFS access points for fine-grained access control |
Source code in mare_aws_common_lib/builders/efs_builder.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
_create_efs_file_system(scope, vpc)
¶
Create the EFS file system with full configuration.
Creates the core EFS file system resource with performance optimization, security configuration, encryption settings, and network placement. Handles both encrypted and unencrypted scenarios with appropriate KMS key integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope for resource creation |
required |
vpc
|
Vpc
|
VPC instance for file system network placement |
required |
Returns:
| Type | Description |
|---|---|
FileSystem
|
Configured EFS FileSystem instance |
Source code in mare_aws_common_lib/builders/efs_builder.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
_create_efs_policy()
¶
Create EFS file system resource policy for service integration.
Generates an IAM policy document that allows necessary EFS operations for AWS service integration, particularly DataSync for backup and migration operations. The policy ensures secure access through mount targets while maintaining proper access controls.
Returns:
| Type | Description |
|---|---|
PolicyDocument
|
IAM PolicyDocument with EFS access permissions for service integration |
Source code in mare_aws_common_lib/builders/efs_builder.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
_get_efs_security_group(scope, vpc)
¶
Retrieve security group for EFS network access control.
Fetches the pre-configured security group that controls network access to the EFS file system, ensuring proper isolation and access patterns for EFS mount operations from authorized sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope for resource lookup |
required |
vpc
|
IVpc
|
VPC instance containing the security group |
required |
Returns:
| Type | Description |
|---|---|
SecurityGroup
|
Security group configured for EFS access patterns |
Note
The security group name follows organizational conventions: "own-efs-sg" and must exist in the target VPC before EFS deployment.
Source code in mare_aws_common_lib/builders/efs_builder.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
_get_security_group_by_name(scope, vpc, sg_name)
¶
Lookup and return an immutable security group reference by name.
Retrieves a security group by name and returns an immutable reference to prevent accidental modification of existing security group rules during infrastructure deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope for resource lookup |
required |
vpc
|
IVpc
|
VPC instance containing the security group |
required |
sg_name
|
str
|
Name of the security group to lookup |
required |
Returns:
| Type | Description |
|---|---|
SecurityGroup
|
Immutable security group reference for safe usage in EFS configuration |
Source code in mare_aws_common_lib/builders/efs_builder.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
_set_config()
¶
Create and validate the EFS configuration from builder inputs.
Combines the builder configuration with the EFS base name to create a validated EfsConfig instance, ensuring all required fields and validation rules are satisfied for successful EFS deployment.
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the combined configuration fails EfsConfig validation. Error details are logged for debugging and troubleshooting. |
Source code in mare_aws_common_lib/builders/efs_builder.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
_store_efs_parameters(scope, file_system, access_points)
¶
Store EFS resource identifiers in SSM Parameter Store with cross-account sharing.
Creates SSM parameters containing EFS file system and access point IDs for consumption by other stacks and services. Handles cross-account parameter sharing for multi-environment deployments where EFS resources in one account need to be accessible from other accounts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope for parameter creation |
required |
file_system
|
FileSystem
|
EFS file system with ID to store |
required |
access_points
|
List[AccessPoint]
|
List of access points with IDs to store |
required |
Source code in mare_aws_common_lib/builders/efs_builder.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
build(scope)
¶
Source code in mare_aws_common_lib/builders/efs_builder.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
reset()
¶
Reset builder state and clear configuration data.
Initializes the builder for a new build cycle by clearing all configuration data and resetting internal state to default values.
Source code in mare_aws_common_lib/builders/efs_builder.py
38 39 40 41 42 43 44 45 46 47 48 | |
set_efs_base_name(name)
¶
Set the base name for the EFS file system.
Configures the fundamental identifier used for naming the EFS file system and related resources including access points and SSM parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base name for the EFS file system (will be combined with environment context) |
required |
Returns:
| Type | Description |
|---|---|
EfsBuilder
|
Self for method chaining |
Source code in mare_aws_common_lib/builders/efs_builder.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |