Skip to content

Commit

Permalink
Add parameterized ECR stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mmajis committed Jun 15, 2021
1 parent 01ab537 commit e786627
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ doesn't appear to support lambda functions packaged as container images.

### AWS SAM

- Edit `sam-deploy.sh` to replace defaults with values from your environment
- Run `sam-deploy.sh`
12 changes: 8 additions & 4 deletions sam-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Options
EOUSAGE
}
awsProfile=()
awsRegion=()
awsRegion="$(aws ec2 describe-availability-zones --output text --query 'AvailabilityZones[0].[RegionName]')"
s3bucket=""
stackName="sam-plantuml"
stackName="plantuml-sam"
repoName="plantuml-sam"
accountId="$(aws sts get-caller-identity --query Account --output text)"
while [[ $# -gt 0 ]]; do
opt="$1"
shift
Expand All @@ -32,6 +34,8 @@ while [[ $# -gt 0 ]]; do
-r|--region) awsRegion=(--region "$1"); shift;;
-b|--bucket) s3bucket="$1"; shift;;
-s|--stack-name) stackName="$1"; shift;;
-a|--account) accountId="$1"; shift;;
-i|--image-repo) repoName="$1"; shift;;
*) echo "Unknown option $opt"; usage; exit 1;;
esac
done
Expand All @@ -57,13 +61,13 @@ sam build --cached

# Edit the AWS account id and region in the repo URL here
aws ecr get-login-password | docker login --username AWS \
--password-stdin 293246570391.dkr.ecr.eu-west-1.amazonaws.com
--password-stdin "${accountId}.dkr.ecr.${awsRegion[*]}.amazonaws.com"

# Replace image-repository with your own
sam deploy "${awsProfile[@]}" "${awsRegion[@]}" \
--stack-name "${stackName}" \
--capabilities CAPABILITY_IAM \
--image-repository 293246570391.dkr.ecr.eu-west-1.amazonaws.com/plantuml-sam \
--image-repository "${accountId}.dkr.ecr.${awsRegion[*]}.amazonaws.com/${repoName}" \
--s3-bucket "${s3bucket}"

#These would be for serverless application repository, but it doesn't support container based lambdas at the moment.
Expand Down

0 comments on commit e786627

Please sign in to comment.