From 6569fd01b5be39b34328c714b3692ad3983b943f Mon Sep 17 00:00:00 2001 From: PG-practice Date: Sun, 25 May 2025 08:19:18 +0000 Subject: [PATCH 1/4] fix: correct AWS::REGION to AWS::Region in template --- iac/pipeline/code-pipeline.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iac/pipeline/code-pipeline.yaml b/iac/pipeline/code-pipeline.yaml index 7e0e9f6..0d5f7f5 100644 --- a/iac/pipeline/code-pipeline.yaml +++ b/iac/pipeline/code-pipeline.yaml @@ -291,7 +291,7 @@ Resources: Image: aws/codebuild/standard:3.0 EnvironmentVariables: - Name: AWS_DEFAULT_REGION - Value: !Ref "AWS::REGION" + Value: !Ref "AWS::Region" - Name: TEMPLATE_BUCKET Value: !Ref rCodePipelineArtifactBucket TimeoutInMinutes: 60 @@ -341,7 +341,7 @@ Resources: PrivilegedMode: true EnvironmentVariables: - Name: AWS_DEFAULT_REGION - Value: !Ref "AWS::REGION" + Value: !Ref "AWS::Region" - Name: S3_BUCKET Value: !Ref rCodePipelineArtifactBucket - Name: REPOSITORY_URI From 8dfbf8eb8e8720994560177ad683fb4f43dc0bb4 Mon Sep 17 00:00:00 2001 From: PG-practice Date: Sun, 25 May 2025 08:20:13 +0000 Subject: [PATCH 2/4] fix: resolve pipeline execution errors --- iac/pipeline/code-pipeline.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iac/pipeline/code-pipeline.yaml b/iac/pipeline/code-pipeline.yaml index 0d5f7f5..9deb43c 100644 --- a/iac/pipeline/code-pipeline.yaml +++ b/iac/pipeline/code-pipeline.yaml @@ -385,7 +385,7 @@ Resources: # Create appspec.yml for CodeDeploy deployment - python iac/code-deploy/scripts/update-appspec.py --taskArn ${TASKDEF_ARN} --hooksLambdaArn ${HOOKS_LAMBDA_ARN} --inputAppSpecFile 'iac/code-deploy/appspec.yml' --outputAppSpecFile '/tmp/appspec.yml' # Create taskdefinition for CodeDeploy deployment - - aws ecs describe-task-definition --task-definition ${TASKDEF_ARN} --region ${AWS_REGION} --query taskDefinition >> taskdef.json + - aws ecs describe-task-definition --task-definition ${TASKDEF_ARN} --region ${AWS_REGION} --query taskDefinition >> /tmp/taskdef.json artifacts: files: - /tmp/appspec.yml @@ -474,7 +474,6 @@ Resources: Capabilities: CAPABILITY_NAMED_IAM RoleArn: !GetAtt rCloudFormationServiceRole.Arn StackName: !Sub ${pApplicationName}-infra-stack - OutputFileName: InfraStackOutput.json TemplateConfiguration: PackagedCFNOutput::iac/app/params/ecs-bg-params.json TemplatePath: PackagedCFNOutput::iac/app/ecs-bg-packaged.yaml ParameterOverrides: | From 880395c63951c95900d863a8baaf6ae9efc81ad7 Mon Sep 17 00:00:00 2001 From: PG-practice Date: Sun, 25 May 2025 08:03:21 +0000 Subject: [PATCH 3/4] chore: remove unused file --- iac/app/templates/codedeploy-deployment.yaml | 61 -------------------- 1 file changed, 61 deletions(-) delete mode 100644 iac/app/templates/codedeploy-deployment.yaml diff --git a/iac/app/templates/codedeploy-deployment.yaml b/iac/app/templates/codedeploy-deployment.yaml deleted file mode 100644 index 97c257e..0000000 --- a/iac/app/templates/codedeploy-deployment.yaml +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: MIT-0 - -AWSTemplateFormatVersion: 2010-09-09 -Description: Creates code deploy deployment for ECS blue/green deployment - -Parameters: - pTaskDefinitionARN: - Description: ECS Task Definition ARN - Type: String - pDeploymentGroupName: - Description: The name of the Deployment Group for ECS CodeDeploy application - Type: String - pCodeDeployAppName: - Description: The name of the ECS CodeDeploy application - Type: String - pContainerPort: - Description: Container name used in the ECS Task definition - Type: String - pContainerName: - Description: Container port used in the ECS Task definition - Type: String - Default: 8080 - -Resources: - rCodeDeployDeploymentResourceFunction: - Type: AWS::Lambda::Function - Properties: - Code: ./../../blue-green/resource/codedeploy - Description: Custom resource lambda for Code-Deploy Deployment - # Handler: index.lambda_handler - Handler: CodeDeployDeploymentLambda.lambda_handler - MemorySize: 128 - Role: !GetAtt rCustomResourceLambdaRole.Arn - Runtime: python3.7 - Timeout: 30 - - rCodeDeployDeploymentResource: - Type: Custom::CodeDeployDeployment - Properties: - ServiceToken: !GetAtt rCodeDeployDeploymentResourceFunction.Arn - applicationName: !Ref pCodeDeployAppName - deploymentGroupName: !Ref pDeploymentGroupName - TaskDefinition: !Ref pTaskDefinitionARN - ContainerName: !Ref pContainerName - ContainerPort: !Ref pContainerPort - - rCustomResourceLambdaRole: - Type: AWS::IAM::Role - Properties: - AssumeRolePolicyDocument: - Version: '2012-10-17' - Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: - - lambda.amazonaws.com - ManagedPolicyArns: - - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole - - arn:aws:iam::aws:policy/AWSCodeDeployDeployerAccess \ No newline at end of file From 07975156c9167f8c9e06f22cfb9179ea51bbb181 Mon Sep 17 00:00:00 2001 From: PG-practice Date: Sun, 25 May 2025 09:03:22 +0000 Subject: [PATCH 4/4] chore: remove hardcode of ECR region --- iac/pipeline/codebuild/buildspec-container.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iac/pipeline/codebuild/buildspec-container.yaml b/iac/pipeline/codebuild/buildspec-container.yaml index 1c5b662..1e6372e 100644 --- a/iac/pipeline/codebuild/buildspec-container.yaml +++ b/iac/pipeline/codebuild/buildspec-container.yaml @@ -12,7 +12,7 @@ phases: pre_build: commands: - echo Logging in to Amazon ECR... - - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $REPOSITORY_URI + - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI - IMAGE_TAG=$(echo $CODEBUILD_SOURCE_VERSION |cut -d/ -f4 |cut -d'.' -f1) - TIMESTAMP=$(date +%Y%m%d%H%M) - echo $IMAGE_TAG