From cb1f120f9a88f1a56e20ca18900c43a883c1a78e Mon Sep 17 00:00:00 2001 From: Simon Kok Date: Mon, 12 Apr 2021 18:12:36 +0200 Subject: [PATCH 1/2] Improve ADF version references in main template **Why?** For each new version of ADF, we need to update the version number in the main template. However, as there are quite a few, it is likely to forget one or search/replace another string that should not have matched. **What?** By adding the version number as a mapping, it can be updated quickly. Reducing the number of times the version is repeated in the template to two. The first usage, in the Serverless Application Repository (SAR) metadata is not able to use intrinsic CloudFormation functions unfortunately. As described in the [SAR Metadata property documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-publishing-applications-metadata-properties.html). --- src/template.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/template.yml b/src/template.yml index 6c0b03174..7d8389ec1 100644 --- a/src/template.yml +++ b/src/template.yml @@ -16,6 +16,10 @@ Metadata: HomePageUrl: https://github.com/awslabs/aws-deployment-framework SemanticVersion: 3.1.2 SourceCodeUrl: https://github.com/awslabs/aws-deployment-framework +Mappings: + Metadata: + ADF: + Version: 3.1.2 Parameters: CrossAccountAccessRoleName: Type: String @@ -175,7 +179,7 @@ Resources: TERMINATION_PROTECTION: false MASTER_ACCOUNT_ID: !Ref AWS::AccountId ORGANIZATION_ID: !GetAtt Organization.OrganizationId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: StackWaiter Role: !GetAtt LambdaRole.Arn @@ -196,7 +200,7 @@ Resources: DEPLOYMENT_ACCOUNT_BUCKET: !GetAtt SharedModulesBucketName.Value MASTER_ACCOUNT_ID: !Ref AWS::AccountId ORGANIZATION_ID: !GetAtt Organization.OrganizationId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: DetermineEventFunction Role: !GetAtt LambdaRole.Arn @@ -217,7 +221,7 @@ Resources: DEPLOYMENT_ACCOUNT_BUCKET: !GetAtt SharedModulesBucketName.Value MASTER_ACCOUNT_ID: !Ref AWS::AccountId ORGANIZATION_ID: !GetAtt Organization.OrganizationId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: CrossAccountExecuteFunction Role: !GetAtt LambdaRole.Arn @@ -236,7 +240,7 @@ Resources: S3_BUCKET_NAME: !Ref BootstrapTemplatesBucket TERMINATION_PROTECTION: false MASTER_ACCOUNT_ID: !Ref AWS::AccountId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: RoleStackDeploymentFunction Role: !GetAtt LambdaRole.Arn @@ -255,7 +259,7 @@ Resources: S3_BUCKET_NAME: !Ref BootstrapTemplatesBucket TERMINATION_PROTECTION: false MASTER_ACCOUNT_ID: !Ref AWS::AccountId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: MovedToRootActionFunction Role: !GetAtt LambdaRole.Arn @@ -274,7 +278,7 @@ Resources: S3_BUCKET_NAME: !Ref BootstrapTemplatesBucket TERMINATION_PROTECTION: false MASTER_ACCOUNT_ID: !Ref AWS::AccountId - ADF_VERSION: 3.1.2 + ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version'] ADF_LOG_LEVEL: INFO FunctionName: UpdateResourcePoliciesFunction Role: !GetAtt LambdaRole.Arn @@ -454,7 +458,7 @@ Resources: Image: "aws/codebuild/standard:5.0" EnvironmentVariables: - Name: ADF_VERSION - Value: 3.1.2 + Value: !FindInMap ['Metadata', 'ADF', 'Version'] - Name: TERMINATION_PROTECTION Value: false - Name: PYTHONPATH @@ -718,7 +722,7 @@ Resources: Type: Custom::InitialCommit Properties: ServiceToken: !GetAtt InitialCommitHandler.Arn - Version: 3.1.2 + Version: !FindInMap ['Metadata', 'ADF', 'Version'] RepositoryArn: !GetAtt CodeCommitRepository.Arn DirectoryName: bootstrap_repository ExistingAccountId: !Ref DeploymentAccountId @@ -939,7 +943,7 @@ Resources: Id: adf-codepipeline-trigger-bootstrap Outputs: ADFVersionNumber: - Value: 3.1.2 + Value: !FindInMap ['Metadata', 'ADF', 'Version'] Export: Name: "ADFVersionNumber" LayerArn: From e3e7a0c227c2458ad41c1c47ccc7399ce219a0ac Mon Sep 17 00:00:00 2001 From: Simon Kok Date: Wed, 14 Apr 2021 17:13:48 +0200 Subject: [PATCH 2/2] Use version metadata on new Version parameter too --- src/template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template.yml b/src/template.yml index 23b044926..dfe735ca3 100644 --- a/src/template.yml +++ b/src/template.yml @@ -779,7 +779,7 @@ Resources: ServiceToken: !GetAtt CrossRegionBucketHandler.Arn Region: !Ref DeploymentAccountMainRegion BucketNamePrefix: !Sub "adf-shared-modules-${DeploymentAccountMainRegion}" - Version: 3.1.2 + Version: !FindInMap ['Metadata', 'ADF', 'Version'] PolicyDocument: Statement: - Action: