From b76fb7c3ef021558dbeb9a3b790aa114deb378df Mon Sep 17 00:00:00 2001 From: Leno Piperi Date: Fri, 23 Aug 2024 14:17:48 -0700 Subject: [PATCH 1/3] removed stack name dependency and replaced with unique ID segment from stack arn instead --- template.yaml | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/template.yaml b/template.yaml index b72a5ae..fe97547 100644 --- a/template.yaml +++ b/template.yaml @@ -472,8 +472,32 @@ Resources: Type: "AWS::CloudFront::OriginAccessControl" Properties: OriginAccessControlConfig: - Description: !Sub "Origin Access Control for static website - ${AWS::StackName}" - Name: !Sub "OAC - ${AWS::StackName}" + Description: + !Join + - '-' + - - 'Origin Access Control for static website' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId + Name: + !Join + - '-' + - - 'OAC' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId OriginAccessControlOriginType: "s3" SigningBehavior: "always" SigningProtocol: "sigv4" @@ -485,7 +509,19 @@ Resources: DependsOn: ServerlessApi Properties: DistributionConfig: - Comment: !Sub "Cloudfront distribution for serverless website - ${AWS::StackName}" + Comment: + !Join + - '-' + - - 'Cloudfront distribution for serverless website' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId DefaultRootObject: "index.html" Enabled: true HttpVersion: http2 From f7cc9e8c919fda93cafd29f900dbae94e64e0fe5 Mon Sep 17 00:00:00 2001 From: Leno Piperi Date: Fri, 23 Aug 2024 15:53:19 -0700 Subject: [PATCH 2/3] removed additional stackname dependencies --- template.yaml | 56 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/template.yaml b/template.yaml index fe97547..6240c82 100644 --- a/template.yaml +++ b/template.yaml @@ -122,7 +122,19 @@ Resources: - AWSMarketplaceMeteringRecords - AWSMarketplaceSubscribers Properties: - RoleName: !Join ["-", [!Ref "AWS::StackName", !Ref CrossAccountRoleName]] + RoleName: + !Join + - '-' + - - 'CrossAccountRoleName' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId AssumeRolePolicyDocument: Version: 2012-10-17 Statement: @@ -137,7 +149,19 @@ Resources: 'sts:ExternalId': !Ref CrossAccountRoleName Path: / Policies: - - PolicyName: !Join ["-", [!Ref "AWS::StackName", "CrossAccountPolicy"]] + - PolicyName: + !Join + - '-' + - - 'CrossAccountPolicy' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId PolicyDocument: Version: 2012-10-17 Statement: @@ -355,14 +379,38 @@ Resources: Type: Schedule Properties: Schedule: "rate(1 hour)" - Name: !Join ["-", [MeteringSchedule, !Ref AWS::StackName]] + Name: + !Join + - '-' + - - 'MeteringSchedule' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId Description: SaaS Metering Enabled: true SQSMeteringRecords: Type: AWS::SQS::Queue Properties: - QueueName: !Join ["-", [!Ref AWS::StackName, SQSMeteringRecords.fifo]] + QueueName: + !Join + - '-' + - - 'SQSMeteringRecords.fifo' + - !Select + - 0 + - !Split + - "-" + - !Select + - 2 + - !Split + - "/" + - !Ref AWS::StackId ContentBasedDeduplication: true FifoQueue: true MessageRetentionPeriod: 3000 From 7759a6a9776660b5073951762f37d33ac5ad7068 Mon Sep 17 00:00:00 2001 From: Leno Piperi Date: Fri, 23 Aug 2024 16:13:53 -0700 Subject: [PATCH 3/3] fixed .fifo suffix issue with sqs queue creation --- template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index 6240c82..0df00d1 100644 --- a/template.yaml +++ b/template.yaml @@ -401,8 +401,7 @@ Resources: QueueName: !Join - '-' - - - 'SQSMeteringRecords.fifo' - - !Select + - - !Select - 0 - !Split - "-" @@ -411,6 +410,7 @@ Resources: - !Split - "/" - !Ref AWS::StackId + - 'SQSMeteringRecords.fifo' ContentBasedDeduplication: true FifoQueue: true MessageRetentionPeriod: 3000