Sha256: 3229e27cc1a09cc4b02d944b8e9dda2fd3543a0eaa14c9cd412031b39e586d4b
Contents?: true
Size: 1.96 KB
Versions: 7
Compression:
Stored size: 1.96 KB
Contents
#!/usr/bin/env bash set -e export DEPLOYMENT_NAME="myorg/APPNAMEHERE" export RAILS_ENV=${RAILS_ENV:="production"} export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1} export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"} # https://github.com/aws/aws-sam-cli/issues/2447 export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}" echo '== Creating ECR repository ==' echo 'You can safely ignore any RepositoryAlreadyExistsException errors...' aws ecr create-repository \ --repository-name "$DEPLOYMENT_NAME" \ --image-tag-mutability MUTABLE \ --image-scanning-configuration scanOnPush=true \ --region "$AWS_DEFAULT_REGION" || true # Build our application code into a deployment folder ./bin/_build export VPCID=${VPCID:=$( aws ec2 describe-vpcs \ --output text \ --filters 'Name=state,Values=available' \ --query 'Vpcs[0].VpcId' )} export SUBNETS=${SUBNETS:=$( aws ec2 describe-subnets \ --output text \ --filters 'Name=state,Values=available' "Name=vpc-id,Values=$VPCID" \ --query 'Subnets[*].SubnetId' | \ tr -s '[:blank:]' ',' )} sam build \ --parameter-overrides \ RailsEnv="${RAILS_ENV}" echo "== SAM package..." sam package \ --region "$AWS_DEFAULT_REGION" \ --template-file ./.aws-sam/build/template.yaml \ --output-template-file ./.aws-sam/build/packaged.yaml \ --image-repository "$IMAGE_REPOSITORY" \ --s3-bucket "${CLOUDFORMATION_BUCKET}" \ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" echo "== SAM deploy..." sam deploy \ --region "$AWS_DEFAULT_REGION" \ --template-file ./.aws-sam/build/packaged.yaml \ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \ --image-repository "$IMAGE_REPOSITORY" \ --capabilities "CAPABILITY_IAM" \ --parameter-overrides \ RailsEnv="${RAILS_ENV}" \ VpcId=${VPCID} \ Subnets=${SUBNETS}
Version data entries
7 entries across 7 versions & 1 rubygems