@fjall/components-infrastructure 0.89.4 → 0.89.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +50 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -18
- package/dist/lib/app.d.ts +12 -12
- package/dist/lib/app.js +61 -56
- package/dist/lib/aspects/index.d.ts +1 -1
- package/dist/lib/aspects/index.js +1 -6
- package/dist/lib/aspects/resourceInventory.js +6 -13
- package/dist/lib/config/audit.js +1 -5
- package/dist/lib/config/aws/accessAnalyser.d.ts +11 -0
- package/dist/lib/config/aws/accessAnalyser.js +17 -0
- package/dist/lib/config/aws/accountAuditRole.js +11 -15
- package/dist/lib/config/aws/accountMonitoringRole.js +25 -29
- package/dist/lib/config/aws/alarmTopic.d.ts +8 -0
- package/dist/lib/config/aws/alarmTopic.js +19 -0
- package/dist/lib/config/aws/cloudTrail.js +4 -9
- package/dist/lib/config/aws/configRecorder.d.ts +16 -0
- package/dist/lib/config/aws/configRecorder.js +51 -0
- package/dist/lib/config/aws/configRulePreset.d.ts +13 -0
- package/dist/lib/config/aws/configRulePreset.js +62 -0
- package/dist/lib/config/aws/disasterRecovery.d.ts +1 -1
- package/dist/lib/config/aws/disasterRecovery.js +56 -73
- package/dist/lib/config/aws/ebsDefaultEncryption.d.ts +8 -0
- package/dist/lib/config/aws/ebsDefaultEncryption.js +41 -0
- package/dist/lib/config/aws/ecrDefaultImage.js +25 -30
- package/dist/lib/config/aws/eventBus.js +8 -11
- package/dist/lib/config/aws/guardDutyDetector.d.ts +16 -0
- package/dist/lib/config/aws/guardDutyDetector.js +26 -0
- package/dist/lib/config/aws/identityCenter.d.ts +1 -1
- package/dist/lib/config/aws/identityCenter.js +23 -25
- package/dist/lib/config/aws/identityCenterGroupMembership.js +18 -22
- package/dist/lib/config/aws/index.d.ts +19 -8
- package/dist/lib/config/aws/index.js +19 -25
- package/dist/lib/config/aws/inspectorEnablement.d.ts +9 -0
- package/dist/lib/config/aws/inspectorEnablement.js +51 -0
- package/dist/lib/config/aws/ipam.js +9 -13
- package/dist/lib/config/aws/oidcConnector.js +8 -12
- package/dist/lib/config/aws/platform.js +1 -5
- package/dist/lib/config/aws/s3BlockPublicAccess.d.ts +9 -0
- package/dist/lib/config/aws/s3BlockPublicAccess.js +55 -0
- package/dist/lib/config/aws/scpPreset.d.ts +21 -0
- package/dist/lib/config/aws/scpPreset.js +311 -0
- package/dist/lib/config/aws/securityBaseline.d.ts +15 -0
- package/dist/lib/config/aws/securityBaseline.js +27 -0
- package/dist/lib/config/aws/securityHubHub.d.ts +15 -0
- package/dist/lib/config/aws/securityHubHub.js +28 -0
- package/dist/lib/config/aws/securityServicesAdmin.d.ts +20 -0
- package/dist/lib/config/aws/securityServicesAdmin.js +115 -0
- package/dist/lib/config/index.d.ts +2 -2
- package/dist/lib/config/index.js +2 -21
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +5 -26
- package/dist/lib/patterns/aws/account.d.ts +17 -1
- package/dist/lib/patterns/aws/account.js +61 -33
- package/dist/lib/patterns/aws/apexDomainPattern.d.ts +26 -0
- package/dist/lib/patterns/aws/apexDomainPattern.js +91 -0
- package/dist/lib/patterns/aws/auditRole.js +13 -16
- package/dist/lib/patterns/aws/buildkite.d.ts +1 -1
- package/dist/lib/patterns/aws/buildkite.js +70 -75
- package/dist/lib/patterns/aws/cdn.d.ts +5 -5
- package/dist/lib/patterns/aws/cdn.js +22 -28
- package/dist/lib/patterns/aws/compute.d.ts +1 -1
- package/dist/lib/patterns/aws/compute.js +31 -44
- package/dist/lib/patterns/aws/computeEc2.d.ts +1 -1
- package/dist/lib/patterns/aws/computeEc2.js +11 -14
- package/dist/lib/patterns/aws/computeEcs.d.ts +18 -2
- package/dist/lib/patterns/aws/computeEcs.js +41 -31
- package/dist/lib/patterns/aws/computeLambda.d.ts +2 -2
- package/dist/lib/patterns/aws/computeLambda.js +24 -31
- package/dist/lib/patterns/aws/database.d.ts +16 -7
- package/dist/lib/patterns/aws/database.js +81 -73
- package/dist/lib/patterns/aws/delegatedDomainPattern.d.ts +17 -0
- package/dist/lib/patterns/aws/delegatedDomainPattern.js +54 -0
- package/dist/lib/patterns/aws/dnsRecordComposer.d.ts +25 -0
- package/dist/lib/patterns/aws/dnsRecordComposer.js +225 -0
- package/dist/lib/patterns/aws/domain.d.ts +32 -0
- package/dist/lib/patterns/aws/domain.js +115 -0
- package/dist/lib/patterns/aws/domainDelegation.d.ts +3 -3
- package/dist/lib/patterns/aws/domainDelegation.js +28 -37
- package/dist/lib/patterns/aws/domainFactory.d.ts +20 -5
- package/dist/lib/patterns/aws/domainFactory.js +48 -10
- package/dist/lib/patterns/aws/domainValidation.d.ts +11 -0
- package/dist/lib/patterns/aws/domainValidation.js +145 -0
- package/dist/lib/patterns/aws/externalRecordsPattern.d.ts +18 -0
- package/dist/lib/patterns/aws/externalRecordsPattern.js +141 -0
- package/dist/lib/patterns/aws/fivetranProxy.d.ts +1 -1
- package/dist/lib/patterns/aws/fivetranProxy.js +6 -11
- package/dist/lib/patterns/aws/index.d.ts +21 -19
- package/dist/lib/patterns/aws/index.js +25 -36
- package/dist/lib/patterns/aws/interfaces/cdn.js +1 -5
- package/dist/lib/patterns/aws/interfaces/compute.js +4 -11
- package/dist/lib/patterns/aws/interfaces/connector.js +1 -15
- package/dist/lib/patterns/aws/interfaces/database.d.ts +1 -1
- package/dist/lib/patterns/aws/interfaces/database.js +6 -15
- package/dist/lib/patterns/aws/interfaces/domain.d.ts +80 -2
- package/dist/lib/patterns/aws/interfaces/domain.js +1 -6
- package/dist/lib/patterns/aws/interfaces/index.js +8 -41
- package/dist/lib/patterns/aws/interfaces/messaging.js +4 -11
- package/dist/lib/patterns/aws/interfaces/organisation.d.ts +1 -1
- package/dist/lib/patterns/aws/interfaces/organisation.js +4 -11
- package/dist/lib/patterns/aws/interfaces/pattern.js +2 -7
- package/dist/lib/patterns/aws/interfaces/storage.js +1 -5
- package/dist/lib/patterns/aws/managedIdentityCenter.js +7 -12
- package/dist/lib/patterns/aws/messaging.d.ts +7 -7
- package/dist/lib/patterns/aws/messaging.js +22 -33
- package/dist/lib/patterns/aws/network.d.ts +2 -2
- package/dist/lib/patterns/aws/network.js +9 -14
- package/dist/lib/patterns/aws/organisation.d.ts +6 -2
- package/dist/lib/patterns/aws/organisation.js +34 -35
- package/dist/lib/patterns/aws/organisationFactory.d.ts +3 -3
- package/dist/lib/patterns/aws/organisationFactory.js +7 -12
- package/dist/lib/patterns/aws/pattern.js +6 -12
- package/dist/lib/patterns/aws/payload.js +73 -63
- package/dist/lib/patterns/aws/platform.d.ts +6 -3
- package/dist/lib/patterns/aws/platform.js +15 -15
- package/dist/lib/patterns/aws/storage.d.ts +6 -4
- package/dist/lib/patterns/aws/storage.js +35 -40
- package/dist/lib/patterns/aws/subdomainHostedZone.js +11 -16
- package/dist/lib/patterns/aws/targets/fjallTargets.d.ts +37 -0
- package/dist/lib/patterns/aws/targets/fjallTargets.js +66 -0
- package/dist/lib/patterns/aws/targets/index.d.ts +2 -0
- package/dist/lib/patterns/aws/targets/index.js +2 -0
- package/dist/lib/patterns/aws/targets/targetResolution.d.ts +76 -0
- package/dist/lib/patterns/aws/targets/targetResolution.js +119 -0
- package/dist/lib/patterns/index.d.ts +1 -0
- package/dist/lib/patterns/index.js +1 -0
- package/dist/lib/resources/aws/analytics/clickhouse.d.ts +15 -0
- package/dist/lib/resources/aws/analytics/clickhouse.js +292 -0
- package/dist/lib/resources/aws/analytics/clickhouseConstants.d.ts +73 -0
- package/dist/lib/resources/aws/analytics/clickhouseConstants.js +87 -0
- package/dist/lib/resources/aws/analytics/clickhouseSecurityGroup.d.ts +13 -0
- package/dist/lib/resources/aws/analytics/clickhouseSecurityGroup.js +28 -0
- package/dist/lib/resources/aws/analytics/clickhouseTypes.d.ts +47 -0
- package/dist/lib/resources/aws/analytics/clickhouseTypes.js +1 -0
- package/dist/lib/resources/aws/analytics/clickhouseUserData.d.ts +5 -0
- package/dist/lib/resources/aws/analytics/clickhouseUserData.js +248 -0
- package/dist/lib/resources/aws/analytics/index.d.ts +2 -0
- package/dist/lib/resources/aws/analytics/index.js +1 -0
- package/dist/lib/resources/aws/audit/auditRole.js +10 -15
- package/dist/lib/resources/aws/audit/index.d.ts +1 -1
- package/dist/lib/resources/aws/audit/index.js +1 -6
- package/dist/lib/resources/aws/backup/backupPlan.d.ts +1 -1
- package/dist/lib/resources/aws/backup/backupPlan.js +14 -16
- package/dist/lib/resources/aws/backup/backupVault.d.ts +1 -1
- package/dist/lib/resources/aws/backup/backupVault.js +13 -15
- package/dist/lib/resources/aws/backup/index.d.ts +2 -2
- package/dist/lib/resources/aws/backup/index.js +2 -19
- package/dist/lib/resources/aws/base/awsStack.js +17 -19
- package/dist/lib/resources/aws/base/index.d.ts +1 -1
- package/dist/lib/resources/aws/base/index.js +1 -18
- package/dist/lib/resources/aws/cdn/cloudFront.js +40 -42
- package/dist/lib/resources/aws/cdn/index.d.ts +1 -1
- package/dist/lib/resources/aws/cdn/index.js +1 -18
- package/dist/lib/resources/aws/compute/ec2.js +39 -39
- package/dist/lib/resources/aws/compute/ecs.d.ts +18 -396
- package/dist/lib/resources/aws/compute/ecs.js +105 -976
- package/dist/lib/resources/aws/compute/ecsCapacityProviderAspect.d.ts +22 -0
- package/dist/lib/resources/aws/compute/ecsCapacityProviderAspect.js +35 -0
- package/dist/lib/resources/aws/compute/ecsConstants.d.ts +20 -0
- package/dist/lib/resources/aws/compute/ecsConstants.js +49 -0
- package/dist/lib/resources/aws/compute/ecsContext.d.ts +12 -0
- package/dist/lib/resources/aws/compute/ecsContext.js +1 -0
- package/dist/lib/resources/aws/compute/ecsImages.d.ts +4 -0
- package/dist/lib/resources/aws/compute/ecsImages.js +35 -0
- package/dist/lib/resources/aws/compute/ecsNetworking.d.ts +28 -0
- package/dist/lib/resources/aws/compute/ecsNetworking.js +290 -0
- package/dist/lib/resources/aws/compute/ecsRoles.d.ts +15 -0
- package/dist/lib/resources/aws/compute/ecsRoles.js +110 -0
- package/dist/lib/resources/aws/compute/ecsServiceFactory.d.ts +33 -0
- package/dist/lib/resources/aws/compute/ecsServiceFactory.js +183 -0
- package/dist/lib/resources/aws/compute/ecsTaskDefinition.d.ts +30 -0
- package/dist/lib/resources/aws/compute/ecsTaskDefinition.js +168 -0
- package/dist/lib/resources/aws/compute/ecsTypes.d.ts +337 -0
- package/dist/lib/resources/aws/compute/ecsTypes.js +10 -0
- package/dist/lib/resources/aws/compute/ecsValidation.d.ts +18 -0
- package/dist/lib/resources/aws/compute/ecsValidation.js +72 -0
- package/dist/lib/resources/aws/compute/index.d.ts +3 -3
- package/dist/lib/resources/aws/compute/index.js +3 -20
- package/dist/lib/resources/aws/compute/lambda.d.ts +10 -2
- package/dist/lib/resources/aws/compute/lambda.js +82 -70
- package/dist/lib/resources/aws/database/dynamodb.js +27 -28
- package/dist/lib/resources/aws/database/index.d.ts +7 -7
- package/dist/lib/resources/aws/database/index.js +14 -33
- package/dist/lib/resources/aws/database/rdsAurora.d.ts +10 -2
- package/dist/lib/resources/aws/database/rdsAurora.js +76 -61
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.d.ts +2 -2
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +24 -21
- package/dist/lib/resources/aws/database/rdsDefaults.js +3 -7
- package/dist/lib/resources/aws/database/rdsHelpers.d.ts +2 -2
- package/dist/lib/resources/aws/database/rdsHelpers.js +21 -29
- package/dist/lib/resources/aws/database/rdsInstance.d.ts +11 -3
- package/dist/lib/resources/aws/database/rdsInstance.js +101 -83
- package/dist/lib/resources/aws/database/rdsProxyOutput.js +5 -9
- package/dist/lib/resources/aws/iam/delegationRole.d.ts +18 -0
- package/dist/lib/resources/aws/iam/delegationRole.js +60 -0
- package/dist/lib/resources/aws/iam/identityCenter/assignment.js +4 -9
- package/dist/lib/resources/aws/iam/identityCenter/group.js +5 -9
- package/dist/lib/resources/aws/iam/identityCenter/index.d.ts +3 -3
- package/dist/lib/resources/aws/iam/identityCenter/index.js +3 -20
- package/dist/lib/resources/aws/iam/identityCenter/permissionSet.d.ts +1 -1
- package/dist/lib/resources/aws/iam/identityCenter/permissionSet.js +5 -9
- package/dist/lib/resources/aws/iam/index.d.ts +5 -4
- package/dist/lib/resources/aws/iam/index.js +5 -21
- package/dist/lib/resources/aws/iam/instanceProfile.js +2 -7
- package/dist/lib/resources/aws/iam/managedPolicy.js +2 -7
- package/dist/lib/resources/aws/iam/policy.js +2 -7
- package/dist/lib/resources/aws/iam/role.js +2 -7
- package/dist/lib/resources/aws/index.d.ts +7 -7
- package/dist/lib/resources/aws/index.js +7 -24
- package/dist/lib/resources/aws/logging/cloudTrail.d.ts +1 -1
- package/dist/lib/resources/aws/logging/cloudTrail.js +18 -22
- package/dist/lib/resources/aws/logging/index.d.ts +2 -2
- package/dist/lib/resources/aws/logging/index.js +2 -19
- package/dist/lib/resources/aws/logging/logGroup.js +4 -10
- package/dist/lib/resources/aws/messaging/eventbridge.js +11 -14
- package/dist/lib/resources/aws/messaging/index.d.ts +4 -4
- package/dist/lib/resources/aws/messaging/index.js +4 -21
- package/dist/lib/resources/aws/messaging/sns.js +11 -14
- package/dist/lib/resources/aws/messaging/sqs.js +32 -34
- package/dist/lib/resources/aws/messaging/utils.d.ts +1 -1
- package/dist/lib/resources/aws/messaging/utils.js +1 -6
- package/dist/lib/resources/aws/monitoring/alarmDefaults.d.ts +36 -0
- package/dist/lib/resources/aws/monitoring/alarmDefaults.js +34 -0
- package/dist/lib/resources/aws/monitoring/ecsAlarms.d.ts +21 -0
- package/dist/lib/resources/aws/monitoring/ecsAlarms.js +88 -0
- package/dist/lib/resources/aws/monitoring/index.d.ts +4 -0
- package/dist/lib/resources/aws/monitoring/index.js +4 -5
- package/dist/lib/resources/aws/monitoring/lambdaAlarms.d.ts +18 -0
- package/dist/lib/resources/aws/monitoring/lambdaAlarms.js +44 -0
- package/dist/lib/resources/aws/monitoring/rdsAlarms.d.ts +20 -0
- package/dist/lib/resources/aws/monitoring/rdsAlarms.js +52 -0
- package/dist/lib/resources/aws/networking/crossAccountDelegationRecord.d.ts +17 -0
- package/dist/lib/resources/aws/networking/crossAccountDelegationRecord.js +26 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aRecord.js +21 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aaaaRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aaaaRecord.js +22 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.js +23 -0
- package/dist/lib/resources/aws/networking/dnsRecord/caaRecord.d.ts +17 -0
- package/dist/lib/resources/aws/networking/dnsRecord/caaRecord.js +21 -0
- package/dist/lib/resources/aws/networking/dnsRecord/cnameRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/cnameRecord.js +22 -0
- package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.d.ts +17 -0
- package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.js +17 -0
- package/dist/lib/resources/aws/networking/dnsRecord/index.d.ts +10 -0
- package/dist/lib/resources/aws/networking/dnsRecord/index.js +10 -0
- package/dist/lib/resources/aws/networking/dnsRecord/mxRecord.d.ts +16 -0
- package/dist/lib/resources/aws/networking/dnsRecord/mxRecord.js +21 -0
- package/dist/lib/resources/aws/networking/dnsRecord/nsRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/nsRecord.js +21 -0
- package/dist/lib/resources/aws/networking/dnsRecord/srvRecord.d.ts +18 -0
- package/dist/lib/resources/aws/networking/dnsRecord/srvRecord.js +21 -0
- package/dist/lib/resources/aws/networking/dnsRecord/txtRecord.d.ts +12 -0
- package/dist/lib/resources/aws/networking/dnsRecord/txtRecord.js +21 -0
- package/dist/lib/resources/aws/networking/domain.d.ts +1 -1
- package/dist/lib/resources/aws/networking/domain.js +32 -34
- package/dist/lib/resources/aws/networking/domainCertificate.d.ts +8 -3
- package/dist/lib/resources/aws/networking/domainCertificate.js +22 -16
- package/dist/lib/resources/aws/networking/hostedZone.d.ts +23 -19
- package/dist/lib/resources/aws/networking/hostedZone.js +70 -134
- package/dist/lib/resources/aws/networking/index.d.ts +8 -7
- package/dist/lib/resources/aws/networking/index.js +8 -24
- package/dist/lib/resources/aws/networking/ipam.js +2 -7
- package/dist/lib/resources/aws/networking/ipamPool.d.ts +1 -1
- package/dist/lib/resources/aws/networking/ipamPool.js +45 -55
- package/dist/lib/resources/aws/networking/securityGroup.js +2 -7
- package/dist/lib/resources/aws/networking/vpc.d.ts +1 -1
- package/dist/lib/resources/aws/networking/vpc.js +17 -21
- package/dist/lib/resources/aws/organisation/costAllocationTagActivator.d.ts +1 -1
- package/dist/lib/resources/aws/organisation/costAllocationTagActivator.js +11 -15
- package/dist/lib/resources/aws/organisation/index.d.ts +5 -5
- package/dist/lib/resources/aws/organisation/index.js +4 -12
- package/dist/lib/resources/aws/organisation/organisation.js +5 -7
- package/dist/lib/resources/aws/organisation/organisationAccount.js +7 -10
- package/dist/lib/resources/aws/organisation/organisationPolicy.js +5 -9
- package/dist/lib/resources/aws/organisation/organisationalUnit.js +1 -3
- package/dist/lib/resources/aws/secrets/alias.js +2 -7
- package/dist/lib/resources/aws/secrets/index.d.ts +4 -4
- package/dist/lib/resources/aws/secrets/index.js +4 -21
- package/dist/lib/resources/aws/secrets/kms.js +15 -18
- package/dist/lib/resources/aws/secrets/parameter.d.ts +3 -3
- package/dist/lib/resources/aws/secrets/parameter.js +19 -22
- package/dist/lib/resources/aws/secrets/secret.d.ts +2 -2
- package/dist/lib/resources/aws/secrets/secret.js +12 -14
- package/dist/lib/resources/aws/storage/ecr.d.ts +2 -2
- package/dist/lib/resources/aws/storage/ecr.js +7 -13
- package/dist/lib/resources/aws/storage/index.d.ts +2 -2
- package/dist/lib/resources/aws/storage/index.js +2 -19
- package/dist/lib/resources/aws/storage/s3.d.ts +1 -1
- package/dist/lib/resources/aws/storage/s3.js +24 -12
- package/dist/lib/resources/aws/utilities/awsCustomResource.js +3 -7
- package/dist/lib/resources/aws/utilities/codeBuild.js +7 -12
- package/dist/lib/resources/aws/utilities/customResource.js +14 -17
- package/dist/lib/resources/aws/utilities/customResourceProvider.js +2 -7
- package/dist/lib/resources/aws/utilities/index.d.ts +5 -5
- package/dist/lib/resources/aws/utilities/index.js +5 -22
- package/dist/lib/resources/aws/utilities/resourceShare.js +2 -7
- package/dist/lib/resources/index.d.ts +1 -1
- package/dist/lib/resources/index.js +1 -18
- package/dist/lib/types.js +1 -3
- package/dist/lib/utils/accountsUtils.d.ts +5 -0
- package/dist/lib/utils/accountsUtils.js +18 -0
- package/dist/lib/utils/addSuffixToEmail.js +1 -5
- package/dist/lib/utils/backupTierMapping.js +2 -6
- package/dist/lib/utils/capitaliseString.js +1 -10
- package/dist/lib/utils/connections.js +9 -13
- package/dist/lib/utils/connector.js +10 -23
- package/dist/lib/utils/constructMap.d.ts +33 -0
- package/dist/lib/utils/constructMap.js +154 -0
- package/dist/lib/utils/databaseTypes.js +4 -10
- package/dist/lib/utils/dnsRecords.d.ts +1 -1
- package/dist/lib/utils/dnsRecords.js +23 -27
- package/dist/lib/utils/domainTypes.d.ts +0 -1
- package/dist/lib/utils/domainTypes.js +2 -10
- package/dist/lib/utils/env.js +14 -26
- package/dist/lib/utils/getAccountId.js +3 -7
- package/dist/lib/utils/getAsync.js +7 -10
- package/dist/lib/utils/getConfig.d.ts +0 -2
- package/dist/lib/utils/getConfig.js +29 -47
- package/dist/lib/utils/getStackOutput.js +4 -8
- package/dist/lib/utils/index.d.ts +12 -12
- package/dist/lib/utils/index.js +12 -29
- package/dist/lib/utils/manifestWriter.d.ts +14 -3
- package/dist/lib/utils/manifestWriter.js +60 -43
- package/dist/lib/utils/orgConfigParser.d.ts +14 -0
- package/dist/lib/utils/orgConfigParser.js +49 -0
- package/dist/lib/utils/removalPolicy.js +5 -9
- package/dist/lib/utils/resourceNaming.js +11 -16
- package/dist/lib/utils/standardTagsAspect.js +9 -16
- package/dist/lib/utils/stripAndCamelCase.js +1 -5
- package/dist/lib/utils/validationLogger.js +12 -18
- package/dist/lib/utils/vpcUtils.js +5 -10
- package/package.json +25 -8
- package/dist/lib/config/aws/accountId.d.ts +0 -6
- package/dist/lib/config/aws/accountId.js +0 -32
- package/dist/lib/config/aws/backupGlobalSettings.d.ts +0 -29
- package/dist/lib/config/aws/backupGlobalSettings.js +0 -49
- package/dist/lib/config/aws/costAllocationTags.d.ts +0 -12
- package/dist/lib/config/aws/costAllocationTags.js +0 -47
- package/dist/lib/config/aws/ipamDelegateAdmin.d.ts +0 -8
- package/dist/lib/config/aws/ipamDelegateAdmin.js +0 -57
- package/dist/lib/config/aws/ipamPoolId.d.ts +0 -16
- package/dist/lib/config/aws/ipamPoolId.js +0 -42
- package/dist/lib/config/aws/organisation.d.ts +0 -30
- package/dist/lib/config/aws/organisation.js +0 -92
- package/dist/lib/config/aws/organisationId.d.ts +0 -7
- package/dist/lib/config/aws/organisationId.js +0 -45
- package/dist/lib/config/aws/organisationsAccess.d.ts +0 -10
- package/dist/lib/config/aws/organisationsAccess.js +0 -49
- package/dist/lib/config/aws/ramSharing.d.ts +0 -4
- package/dist/lib/config/aws/ramSharing.js +0 -34
- package/dist/lib/config/monitoring.d.ts +0 -18
- package/dist/lib/config/monitoring.js +0 -22
- package/dist/lib/patterns/aws/connections.d.ts +0 -46
- package/dist/lib/patterns/aws/connections.js +0 -159
- package/dist/lib/patterns/aws/hostedZone.d.ts +0 -28
- package/dist/lib/patterns/aws/hostedZone.js +0 -150
- package/dist/lib/patterns/aws/managedAccount.d.ts +0 -9
- package/dist/lib/patterns/aws/managedAccount.js +0 -55
- package/dist/lib/patterns/aws/managedOrganisation.d.ts +0 -36
- package/dist/lib/patterns/aws/managedOrganisation.js +0 -97
- package/dist/lib/patterns/aws/managedPlatform.d.ts +0 -12
- package/dist/lib/patterns/aws/managedPlatform.js +0 -29
- package/dist/lib/resources/aws/database/database.d.ts +0 -14
- package/dist/lib/resources/aws/database/database.js +0 -28
- package/dist/lib/resources/aws/database/databaseInstance.d.ts +0 -15
- package/dist/lib/resources/aws/database/databaseInstance.js +0 -30
- package/dist/lib/resources/aws/database/migrationLambda.d.ts +0 -80
- package/dist/lib/resources/aws/database/migrationLambda.js +0 -119
- package/dist/lib/resources/aws/iam/identityCenter/attachManagedPolicy.d.ts +0 -13
- package/dist/lib/resources/aws/iam/identityCenter/attachManagedPolicy.js +0 -51
- package/dist/lib/resources/aws/iam/securityGroup.d.ts +0 -5
- package/dist/lib/resources/aws/iam/securityGroup.js +0 -14
- package/dist/lib/resources/aws/monitoring/monitoringRole.d.ts +0 -29
- package/dist/lib/resources/aws/monitoring/monitoringRole.js +0 -120
- package/dist/lib/utils/capitalizeString.d.ts +0 -12
- package/dist/lib/utils/capitalizeString.js +0 -30
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { FargateService, Ec2Service, PropagatedTagSource, PlacementStrategy, AsgCapacityProvider, EcsOptimizedImage, AmiHardwareType } from "aws-cdk-lib/aws-ecs";
|
|
2
|
+
import { InstanceType, Peer, Port, SubnetType } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import { CfnOutput, Duration } from "aws-cdk-lib";
|
|
4
|
+
import { PredefinedMetric, ScalableTarget, ServiceNamespace, TargetTrackingScalingPolicy } from "aws-cdk-lib/aws-applicationautoscaling";
|
|
5
|
+
import { AutoScalingGroup, Monitoring } from "aws-cdk-lib/aws-autoscaling";
|
|
6
|
+
import { SecurityGroup } from "../networking/securityGroup.js";
|
|
7
|
+
import { vpcHasNatGateways } from "../../../utils/vpcUtils.js";
|
|
8
|
+
import { toPascalCase } from "../../../utils/capitaliseString.js";
|
|
9
|
+
import { DEFAULT_EC2_INSTANCE_TYPE, DEFAULT_WARM_POOL_MIN_SIZE, DEFAULT_WARM_POOL_REUSE_ON_SCALE_IN, inferAmiHardwareType } from "./ecsConstants.js";
|
|
10
|
+
import { ScalingType } from "./ecsTypes.js";
|
|
11
|
+
import { isServiceFargate, isServiceEc2 } from "./ecsTaskDefinition.js";
|
|
12
|
+
/**
|
|
13
|
+
* Generates a unique key for EC2 config so services with matching
|
|
14
|
+
* configurations share an ASG.
|
|
15
|
+
*/
|
|
16
|
+
export function getEc2ConfigKey(ec2Config) {
|
|
17
|
+
const instanceType = ec2Config.instanceType ?? DEFAULT_EC2_INSTANCE_TYPE;
|
|
18
|
+
const amiHardwareType = ec2Config.amiHardwareType ??
|
|
19
|
+
(inferAmiHardwareType(instanceType) === AmiHardwareType.ARM
|
|
20
|
+
? "ARM"
|
|
21
|
+
: "STANDARD");
|
|
22
|
+
const warmPoolKey = ec2Config.warmPool
|
|
23
|
+
? `wp${ec2Config.warmPool.minSize ?? DEFAULT_WARM_POOL_MIN_SIZE}-${ec2Config.warmPool.reuseOnScaleIn ?? DEFAULT_WARM_POOL_REUSE_ON_SCALE_IN}`
|
|
24
|
+
: "nowp";
|
|
25
|
+
return `${instanceType}-${amiHardwareType}-${warmPoolKey}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets or creates an ASG capacity provider for an EC2-backed service.
|
|
29
|
+
* Services with matching EC2 configs share the same ASG.
|
|
30
|
+
*
|
|
31
|
+
* Mutates `state` to track the provider and first ASG/security group.
|
|
32
|
+
*/
|
|
33
|
+
export function getOrCreateAsgCapacityProvider(ctx, serviceProps, state) {
|
|
34
|
+
const ec2Config = serviceProps.ec2Config ?? {};
|
|
35
|
+
const key = getEc2ConfigKey(ec2Config);
|
|
36
|
+
const existing = state.providers.get(key);
|
|
37
|
+
if (existing) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
const safeKey = key.replace(/[^a-zA-Z0-9]/g, "");
|
|
41
|
+
const instanceType = ec2Config.instanceType ?? DEFAULT_EC2_INSTANCE_TYPE;
|
|
42
|
+
const amiHardwareType = ec2Config.amiHardwareType
|
|
43
|
+
? ec2Config.amiHardwareType === "STANDARD"
|
|
44
|
+
? AmiHardwareType.STANDARD
|
|
45
|
+
: AmiHardwareType.ARM
|
|
46
|
+
: inferAmiHardwareType(instanceType);
|
|
47
|
+
const minCapacity = ec2Config.minCapacity ?? 2;
|
|
48
|
+
const maxCapacity = ec2Config.maxCapacity ?? 3;
|
|
49
|
+
const asgSecurityGroup = new SecurityGroup(ctx.scope, `${safeKey}AsgSecurityGroup`, {
|
|
50
|
+
vpc: ctx.cluster.vpc,
|
|
51
|
+
description: `Security group for ${key} auto scaling group`
|
|
52
|
+
});
|
|
53
|
+
if (ctx.directAccessEnabled) {
|
|
54
|
+
for (const service of ctx.props.services) {
|
|
55
|
+
if (isServiceEc2(service)) {
|
|
56
|
+
for (const container of service.containers) {
|
|
57
|
+
if (container.port) {
|
|
58
|
+
asgSecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(container.port), `Direct access to container port ${container.port}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const hasNat = vpcHasNatGateways(ctx.cluster.vpc);
|
|
65
|
+
const asg = new AutoScalingGroup(ctx.scope, `${safeKey}AutoScalingGroup`, {
|
|
66
|
+
autoScalingGroupName: `${ctx.props.clusterName}-${safeKey}-Asg`,
|
|
67
|
+
vpc: ctx.cluster.vpc,
|
|
68
|
+
vpcSubnets: {
|
|
69
|
+
subnetType: hasNat ? SubnetType.PRIVATE_WITH_EGRESS : SubnetType.PUBLIC
|
|
70
|
+
},
|
|
71
|
+
securityGroup: asgSecurityGroup,
|
|
72
|
+
minCapacity,
|
|
73
|
+
maxCapacity,
|
|
74
|
+
instanceType: new InstanceType(instanceType),
|
|
75
|
+
capacityRebalance: true,
|
|
76
|
+
instanceMonitoring: Monitoring.BASIC,
|
|
77
|
+
machineImage: EcsOptimizedImage.amazonLinux2023(amiHardwareType)
|
|
78
|
+
});
|
|
79
|
+
if (ec2Config.warmPool) {
|
|
80
|
+
asg.addWarmPool({
|
|
81
|
+
minSize: ec2Config.warmPool.minSize ?? DEFAULT_WARM_POOL_MIN_SIZE,
|
|
82
|
+
reuseOnScaleIn: ec2Config.warmPool.reuseOnScaleIn ?? DEFAULT_WARM_POOL_REUSE_ON_SCALE_IN
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const provider = new AsgCapacityProvider(ctx.scope, `${safeKey}AsgCapacityProvider`, {
|
|
86
|
+
autoScalingGroup: asg,
|
|
87
|
+
enableManagedDraining: true,
|
|
88
|
+
enableManagedTerminationProtection: false
|
|
89
|
+
});
|
|
90
|
+
ctx.cluster.addAsgCapacityProvider(provider);
|
|
91
|
+
state.providers.set(key, provider);
|
|
92
|
+
if (!state.autoScalingGroup) {
|
|
93
|
+
state.autoScalingGroup = asg;
|
|
94
|
+
}
|
|
95
|
+
if (!state.asgSecurityGroup) {
|
|
96
|
+
state.asgSecurityGroup = asgSecurityGroup;
|
|
97
|
+
}
|
|
98
|
+
return provider;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a Fargate or EC2 service and emits a CfnOutput for its ARN.
|
|
102
|
+
*/
|
|
103
|
+
export function createService(ctx, serviceName, serviceProps, taskDefinition, asgState) {
|
|
104
|
+
const desiredCount = serviceProps.desiredCount ?? 2;
|
|
105
|
+
let service;
|
|
106
|
+
if (isServiceFargate(serviceProps)) {
|
|
107
|
+
const hasNat = vpcHasNatGateways(ctx.cluster.vpc);
|
|
108
|
+
service = new FargateService(ctx.scope, `${serviceName}Service`, {
|
|
109
|
+
cluster: ctx.cluster,
|
|
110
|
+
taskDefinition: taskDefinition,
|
|
111
|
+
desiredCount,
|
|
112
|
+
serviceName,
|
|
113
|
+
vpcSubnets: {
|
|
114
|
+
subnetType: hasNat ? SubnetType.PRIVATE_WITH_EGRESS : SubnetType.PUBLIC
|
|
115
|
+
},
|
|
116
|
+
assignPublicIp: !hasNat,
|
|
117
|
+
capacityProviderStrategies: [
|
|
118
|
+
{
|
|
119
|
+
capacityProvider: serviceProps.capacityProvider,
|
|
120
|
+
weight: 1
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
propagateTags: PropagatedTagSource.SERVICE,
|
|
124
|
+
circuitBreaker: { enable: true, rollback: true },
|
|
125
|
+
enableECSManagedTags: true,
|
|
126
|
+
enableExecuteCommand: true,
|
|
127
|
+
healthCheckGracePeriod: Duration.seconds(120),
|
|
128
|
+
minHealthyPercent: 100,
|
|
129
|
+
maxHealthyPercent: 200
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const asgProvider = getOrCreateAsgCapacityProvider(ctx, serviceProps, asgState);
|
|
134
|
+
service = new Ec2Service(ctx.scope, `${serviceName}Service`, {
|
|
135
|
+
cluster: ctx.cluster,
|
|
136
|
+
taskDefinition: taskDefinition,
|
|
137
|
+
desiredCount,
|
|
138
|
+
serviceName,
|
|
139
|
+
capacityProviderStrategies: [
|
|
140
|
+
{
|
|
141
|
+
capacityProvider: asgProvider.capacityProviderName,
|
|
142
|
+
weight: 1
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
propagateTags: PropagatedTagSource.SERVICE,
|
|
146
|
+
circuitBreaker: { enable: true, rollback: true },
|
|
147
|
+
placementStrategies: [PlacementStrategy.spreadAcrossInstances()],
|
|
148
|
+
enableECSManagedTags: true,
|
|
149
|
+
enableExecuteCommand: true,
|
|
150
|
+
healthCheckGracePeriod: Duration.seconds(120),
|
|
151
|
+
minHealthyPercent: 100,
|
|
152
|
+
maxHealthyPercent: 200
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
new CfnOutput(ctx.scope, `${ctx.outputName}${toPascalCase(serviceName)}ServiceArn`, {
|
|
156
|
+
key: `${ctx.outputName}${toPascalCase(serviceName)}ServiceArn`,
|
|
157
|
+
exportName: `${ctx.props.clusterName}${serviceName}ServiceArn`,
|
|
158
|
+
value: service.serviceArn,
|
|
159
|
+
description: `ECS Service ARN for ${serviceName}`
|
|
160
|
+
});
|
|
161
|
+
return service;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Adds auto-scaling to an ECS service based on CPU or memory utilisation.
|
|
165
|
+
*/
|
|
166
|
+
export function addServiceScaling(ctx, serviceName, serviceProps, service) {
|
|
167
|
+
const scalableTarget = new ScalableTarget(ctx.scope, `${serviceName}ScalableTarget`, {
|
|
168
|
+
serviceNamespace: ServiceNamespace.ECS,
|
|
169
|
+
resourceId: `service/${ctx.cluster.clusterName}/${service.serviceName}`,
|
|
170
|
+
scalableDimension: "ecs:service:DesiredCount",
|
|
171
|
+
minCapacity: serviceProps.minCapacity ?? 2,
|
|
172
|
+
maxCapacity: serviceProps.maxCapacity ?? 10
|
|
173
|
+
});
|
|
174
|
+
return new TargetTrackingScalingPolicy(ctx.scope, `${serviceName}ScalingPolicy`, {
|
|
175
|
+
scalingTarget: scalableTarget,
|
|
176
|
+
predefinedMetric: serviceProps.scalingType === ScalingType.MEMORY
|
|
177
|
+
? PredefinedMetric.ECS_SERVICE_AVERAGE_MEMORY_UTILIZATION
|
|
178
|
+
: PredefinedMetric.ECS_SERVICE_AVERAGE_CPU_UTILIZATION,
|
|
179
|
+
targetValue: 50,
|
|
180
|
+
scaleInCooldown: Duration.seconds(60),
|
|
181
|
+
scaleOutCooldown: Duration.seconds(60)
|
|
182
|
+
});
|
|
183
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FargateTaskDefinition, Ec2TaskDefinition, type ContainerDefinition } from "aws-cdk-lib/aws-ecs";
|
|
2
|
+
import { type Role } from "aws-cdk-lib/aws-iam";
|
|
3
|
+
import type { EcsConstructContext } from "./ecsContext.js";
|
|
4
|
+
import type { EcsClusterProps, EcsServiceProps, EcsCapacityProvider } from "./ecsTypes.js";
|
|
5
|
+
export { createExecutionRole, createTaskRole } from "./ecsRoles.js";
|
|
6
|
+
export { getContainerImage } from "./ecsImages.js";
|
|
7
|
+
/**
|
|
8
|
+
* Gets the capacity provider for a service.
|
|
9
|
+
* Each service MUST specify its own capacityProvider.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getServiceCapacityProvider(serviceProps: EcsServiceProps): EcsCapacityProvider;
|
|
12
|
+
/** Checks if a service uses a Fargate capacity provider. */
|
|
13
|
+
export declare function isServiceFargate(serviceProps: EcsServiceProps): boolean;
|
|
14
|
+
/** Checks if a service uses an EC2 capacity provider. */
|
|
15
|
+
export declare function isServiceEc2(serviceProps: EcsServiceProps): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Collects Secrets Manager secret names from secretsImport for a specific service.
|
|
18
|
+
* Scoped per service to enforce least-privilege on execution roles.
|
|
19
|
+
*/
|
|
20
|
+
export declare function collectSecretsManagerSecretNames(props: EcsClusterProps, serviceName: string): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Derives the SSM secrets path for a service.
|
|
23
|
+
* Uses explicit path if provided, otherwise derives from app/cluster/service names.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deriveSsmSecretsPath(props: EcsClusterProps, serviceName: string, explicitPath?: string): string;
|
|
26
|
+
export declare function createTaskDefinition(ctx: EcsConstructContext, serviceName: string, serviceProps: EcsServiceProps, executionRole: Role, taskRole: Role): FargateTaskDefinition | Ec2TaskDefinition;
|
|
27
|
+
export declare function addContainersToTask(ctx: EcsConstructContext, serviceName: string, serviceProps: EcsServiceProps, taskDefinition: FargateTaskDefinition | Ec2TaskDefinition): {
|
|
28
|
+
containers: ContainerDefinition[];
|
|
29
|
+
primaryContainer?: ContainerDefinition;
|
|
30
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { AwsLogDriver, FargateTaskDefinition, Ec2TaskDefinition, NetworkMode, CpuArchitecture, OperatingSystemFamily } from "aws-cdk-lib/aws-ecs";
|
|
2
|
+
import { Duration } from "aws-cdk-lib";
|
|
3
|
+
import { Secret as EcsSecret } from "aws-cdk-lib/aws-ecs";
|
|
4
|
+
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
|
5
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
6
|
+
import { validateSsmPathComponent } from "./ecsValidation.js";
|
|
7
|
+
import { DEFAULT_LOG_RETENTION_DAYS } from "./ecsConstants.js";
|
|
8
|
+
import { getContainerImage } from "./ecsImages.js";
|
|
9
|
+
// Re-export extracted functions so existing consumers are not broken
|
|
10
|
+
export { createExecutionRole, createTaskRole } from "./ecsRoles.js";
|
|
11
|
+
export { getContainerImage } from "./ecsImages.js";
|
|
12
|
+
/**
|
|
13
|
+
* Gets the capacity provider for a service.
|
|
14
|
+
* Each service MUST specify its own capacityProvider.
|
|
15
|
+
*/
|
|
16
|
+
export function getServiceCapacityProvider(serviceProps) {
|
|
17
|
+
return serviceProps.capacityProvider;
|
|
18
|
+
}
|
|
19
|
+
/** Checks if a service uses a Fargate capacity provider. */
|
|
20
|
+
export function isServiceFargate(serviceProps) {
|
|
21
|
+
const provider = getServiceCapacityProvider(serviceProps);
|
|
22
|
+
return provider === "FARGATE" || provider === "FARGATE_SPOT";
|
|
23
|
+
}
|
|
24
|
+
/** Checks if a service uses an EC2 capacity provider. */
|
|
25
|
+
export function isServiceEc2(serviceProps) {
|
|
26
|
+
return getServiceCapacityProvider(serviceProps) === "EC2";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Collects Secrets Manager secret names from secretsImport for a specific service.
|
|
30
|
+
* Scoped per service to enforce least-privilege on execution roles.
|
|
31
|
+
*/
|
|
32
|
+
export function collectSecretsManagerSecretNames(props, serviceName) {
|
|
33
|
+
const service = props.services.find((s) => s.name === serviceName);
|
|
34
|
+
if (!service)
|
|
35
|
+
return [];
|
|
36
|
+
const secretNames = new Set();
|
|
37
|
+
for (const container of service.containers) {
|
|
38
|
+
if (container.secretsImport) {
|
|
39
|
+
for (const secretImport of Object.values(container.secretsImport)) {
|
|
40
|
+
secretNames.add(secretImport.name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return Array.from(secretNames);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Derives the SSM secrets path for a service.
|
|
48
|
+
* Uses explicit path if provided, otherwise derives from app/cluster/service names.
|
|
49
|
+
*/
|
|
50
|
+
export function deriveSsmSecretsPath(props, serviceName, explicitPath) {
|
|
51
|
+
if (explicitPath) {
|
|
52
|
+
return explicitPath;
|
|
53
|
+
}
|
|
54
|
+
const appName = props.appName;
|
|
55
|
+
if (!appName) {
|
|
56
|
+
throw new Error(`Service '${serviceName}' has secrets defined but no ssmSecretsPath is set ` +
|
|
57
|
+
`and appName is not configured on the cluster. ` +
|
|
58
|
+
`Either set ssmSecretsPath on the service, or set appName on the cluster props ` +
|
|
59
|
+
`to enable automatic path derivation (/<appName>/<clusterName>/<serviceName>).`);
|
|
60
|
+
}
|
|
61
|
+
validateSsmPathComponent(appName, "appName");
|
|
62
|
+
validateSsmPathComponent(props.clusterName, "clusterName");
|
|
63
|
+
validateSsmPathComponent(serviceName, "serviceName");
|
|
64
|
+
return `/${appName}/${props.clusterName}/${serviceName}`;
|
|
65
|
+
}
|
|
66
|
+
export function createTaskDefinition(ctx, serviceName, serviceProps, executionRole, taskRole) {
|
|
67
|
+
const cpu = serviceProps.cpu ?? 256;
|
|
68
|
+
const memoryLimitMiB = serviceProps.memoryLimitMiB ?? 512;
|
|
69
|
+
if (isServiceFargate(serviceProps)) {
|
|
70
|
+
return new FargateTaskDefinition(ctx.scope, `${serviceName}TaskDefinition`, {
|
|
71
|
+
family: `${ctx.props.clusterName}-${serviceName}`,
|
|
72
|
+
cpu,
|
|
73
|
+
memoryLimitMiB,
|
|
74
|
+
executionRole,
|
|
75
|
+
taskRole,
|
|
76
|
+
runtimePlatform: {
|
|
77
|
+
cpuArchitecture: CpuArchitecture.ARM64,
|
|
78
|
+
operatingSystemFamily: OperatingSystemFamily.LINUX
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return new Ec2TaskDefinition(ctx.scope, `${serviceName}TaskDefinition`, {
|
|
84
|
+
family: `${ctx.props.clusterName}-${serviceName}`,
|
|
85
|
+
executionRole,
|
|
86
|
+
taskRole,
|
|
87
|
+
...(ctx.directAccessEnabled && { networkMode: NetworkMode.HOST })
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function addContainersToTask(ctx, serviceName, serviceProps, taskDefinition) {
|
|
92
|
+
const containers = [];
|
|
93
|
+
let primaryContainer;
|
|
94
|
+
for (const containerConfig of serviceProps.containers) {
|
|
95
|
+
const image = getContainerImage(ctx, serviceName, containerConfig, serviceProps);
|
|
96
|
+
const isFirstWithPort = !primaryContainer && containerConfig.port !== undefined;
|
|
97
|
+
const secrets = {};
|
|
98
|
+
if (containerConfig.secretsImport) {
|
|
99
|
+
for (const [key, secretImport] of Object.entries(containerConfig.secretsImport)) {
|
|
100
|
+
const secret = Secret.fromSecretNameV2(ctx.scope, `${ctx.props.clusterName}${serviceName}${containerConfig.name}${key}Secret`, secretImport.name);
|
|
101
|
+
secrets[key] = EcsSecret.fromSecretsManager(secret, secretImport.field);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (containerConfig.secrets && containerConfig.secrets.length > 0) {
|
|
105
|
+
if (containerConfig.secretsImport) {
|
|
106
|
+
const secretsImportKeys = Object.keys(containerConfig.secretsImport);
|
|
107
|
+
const duplicateKeys = containerConfig.secrets.filter((key) => secretsImportKeys.includes(key));
|
|
108
|
+
if (duplicateKeys.length > 0) {
|
|
109
|
+
throw new Error(`Container '${containerConfig.name}' in service '${serviceName}' has duplicate secret keys ` +
|
|
110
|
+
`defined in both secrets and secretsImport: ${duplicateKeys.join(", ")}. ` +
|
|
111
|
+
`Each secret key must be unique across both sources.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const ssmSecretsPath = deriveSsmSecretsPath(ctx.props, serviceName, serviceProps.ssmSecretsPath);
|
|
115
|
+
for (const secretName of containerConfig.secrets) {
|
|
116
|
+
const paramPath = `${ssmSecretsPath}/${secretName}`;
|
|
117
|
+
const param = StringParameter.fromSecureStringParameterAttributes(ctx.scope, `${ctx.props.clusterName}${serviceName}${containerConfig.name}${secretName}SsmParam`, { parameterName: paramPath });
|
|
118
|
+
secrets[secretName] = EcsSecret.fromSsmParameter(param);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const container = taskDefinition.addContainer(`${serviceName}${containerConfig.name}`, {
|
|
122
|
+
image,
|
|
123
|
+
containerName: containerConfig.name,
|
|
124
|
+
logging: new AwsLogDriver({
|
|
125
|
+
streamPrefix: `/ecs/${ctx.props.clusterName}/${serviceName}`,
|
|
126
|
+
logRetention: DEFAULT_LOG_RETENTION_DAYS
|
|
127
|
+
}),
|
|
128
|
+
environment: {
|
|
129
|
+
...containerConfig.environment,
|
|
130
|
+
...(containerConfig.port
|
|
131
|
+
? { PORT: String(containerConfig.port) }
|
|
132
|
+
: {})
|
|
133
|
+
},
|
|
134
|
+
secrets,
|
|
135
|
+
command: containerConfig.command,
|
|
136
|
+
entryPoint: containerConfig.entryPoint,
|
|
137
|
+
essential: containerConfig.essential ?? true,
|
|
138
|
+
healthCheck: containerConfig.healthCheck
|
|
139
|
+
? {
|
|
140
|
+
command: containerConfig.healthCheck.command,
|
|
141
|
+
interval: containerConfig.healthCheck.interval
|
|
142
|
+
? Duration.seconds(containerConfig.healthCheck.interval)
|
|
143
|
+
: undefined,
|
|
144
|
+
timeout: containerConfig.healthCheck.timeout
|
|
145
|
+
? Duration.seconds(containerConfig.healthCheck.timeout)
|
|
146
|
+
: undefined,
|
|
147
|
+
retries: containerConfig.healthCheck.retries,
|
|
148
|
+
startPeriod: containerConfig.healthCheck.startPeriod
|
|
149
|
+
? Duration.seconds(containerConfig.healthCheck.startPeriod)
|
|
150
|
+
: undefined
|
|
151
|
+
}
|
|
152
|
+
: undefined,
|
|
153
|
+
...(isServiceEc2(serviceProps) && {
|
|
154
|
+
memoryLimitMiB: serviceProps.ec2Config?.memoryLimitMiB ?? 1024
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
if (containerConfig.port) {
|
|
158
|
+
container.addPortMappings({
|
|
159
|
+
containerPort: containerConfig.port
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (isFirstWithPort) {
|
|
163
|
+
primaryContainer = container;
|
|
164
|
+
}
|
|
165
|
+
containers.push(container);
|
|
166
|
+
}
|
|
167
|
+
return { containers, primaryContainer };
|
|
168
|
+
}
|