From 008f84a252ad4b469900e10b4a0d9a4ae83083f9 Mon Sep 17 00:00:00 2001 From: Joe Bailey Date: Sun, 12 Feb 2023 15:21:47 -0800 Subject: [PATCH] WIP commit to create a comparison with the ECS blue green repo, specifically the fargate branch changes. --- infra/templates/deployment-pipeline.yaml | 22 +++++++++---------- infra/templates/service.yaml | 28 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/infra/templates/deployment-pipeline.yaml b/infra/templates/deployment-pipeline.yaml index acde08b22..2aa845e05 100644 --- a/infra/templates/deployment-pipeline.yaml +++ b/infra/templates/deployment-pipeline.yaml @@ -222,13 +222,12 @@ Resources: - echo -n "$CODEBUILD_LOG_PATH" > /tmp/build_id.out - printf "%s:%s" "$REPOSITORY_URI" "$(cat /tmp/build_id.out)" > /tmp/build_tag.out - printf '{"tag":"%s"}' "$(cat /tmp/build_id.out)" > /tmp/build.json - # - $(aws ecr get-login-password) + - echo Logging in to Amazon ECR... + - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin "$(aws sts get-caller-identity --query \"Account\" --output text)".dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com build: commands: - - ./mvnw package + - ./mvnw package -DskipTests - docker build --tag "$(cat /tmp/build_tag.out)" . - # - ./mvnw spring-boot:build-image - - docker image tag spring-petclinic:3.0.0-SNAPSHOT "$(cat /tmp/build_tag.out)" post_build: commands: - docker push "$(cat /tmp/build_tag.out)" @@ -239,13 +238,12 @@ Resources: ComputeType: "BUILD_GENERAL1_SMALL" Image: "aws/codebuild/standard:6.0" Type: "LINUX_CONTAINER" + PrivilegedMode: true EnvironmentVariables: - Name: AWS_DEFAULT_REGION Value: !Ref AWS::Region - Name: REPOSITORY_URI Value: !Sub ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${Repository} - - Name: DOCKER_HOST - Value: unix:///var/run/docker.sock Name: !Sub ${AWS::StackName}-codebuildproject ServiceRole: !Ref CodeBuildServiceRole @@ -259,11 +257,11 @@ Resources: BuildSpec: | version: 0.1 phases: - install: - commands: - - pip install --upgrade python - - pip install --upgrade awscli - - pip install --upgrade boto3 + # install: + # commands: + # - pip install --upgrade python + # - pip install --upgrade awscli + # - pip install --upgrade boto3 pre_build: commands: - printenv @@ -274,7 +272,7 @@ Resources: discard-paths: yes Environment: ComputeType: "BUILD_GENERAL1_SMALL" - Image: aws/codebuild/python:2.7.12 + Image: "aws/codebuild/standard:6.0" Type: "LINUX_CONTAINER" EnvironmentVariables: - Name: AWS_DEFAULT_REGION diff --git a/infra/templates/service.yaml b/infra/templates/service.yaml index cd944ac5d..1d0455aa7 100644 --- a/infra/templates/service.yaml +++ b/infra/templates/service.yaml @@ -31,9 +31,7 @@ Parameters: IsProduction: Type: String - Resources: - LoadBalancerListener: Type: AWS::ElasticLoadBalancingV2::Listener Properties: @@ -77,7 +75,7 @@ Resources: Conditions: - Field: path-pattern Values: - - "*" + - "*" ListenerArn: !Ref LoadBalancerListener Priority: 1 @@ -104,15 +102,37 @@ Resources: Role: !Ref ECSServiceRole DesiredCount: !Ref DesiredCount TaskDefinition: !Ref TaskDefinition + # CapacityProviderStrategy: + # - CapacityProvider: FARGATE + # - Base: 0 + # - Weight: 1 LoadBalancers: - ContainerName: simple-app ContainerPort: 80 TargetGroupArn: !Ref TargetGroup + # NetworkConfiguration: + # - AwsvpcConfiguration: + # - AssignPublicIp: ENABLED + # - SecurityGroups: + # - Ref: SecurityGroupIDs + # - Subnets: !!omap + # - Ref: SubnetIDs + PlatformVersion: LATEST + # DeploymentConfiguration: + # - MaximumPercent: 200 + # - MinimumHealthyPercent: 100 + # - DeploymentCircuitBreaker: + # - Enable: true + # - Rollback: true + # DeploymentController: + # - Type: ECS + # ServiceConnectConfiguration: + # - Enabled: false TaskDefinition: Type: AWS::ECS::TaskDefinition Properties: - #Family: !Sub ${AWS::StackName}-simple-app + Family: !Sub ${AWS::StackName}-simple-app ContainerDefinitions: - Name: simple-app Image: !Sub ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${Repository}:${Tag}