Skip to content

ydvsailendar/ways-of-aws-lambda-deployment-with-tf

Repository files navigation

README

Pre-requisite

Command

Create S3 and ECR

# create s3 bucket
aws s3api create-bucket --bucket <terraform_state_bucket_name> --profile <aws_profile> --region <aws_region> --create-bucket-configuration LocationConstraint=<aws_region>
# enable versioning in the created bucket
aws s3api put-bucket-versioning --bucket <terraform_state_bucket_name> --versioning-configuration Status=Enabled --profile <aws_profile> --region <aws_region>
# create ecr repo
aws ecr create-repository --repository-name <ecr_repo_name> --profile <aws_profile> --region <aws_region>
# set repo permission so that lambda can pull image
aws ecr set-repository-policy --repository-name <ecr_repo_name> --profile <aws_profile> --region <aws_region> --policy-text file://ecr-policy.json
# docker client authentication with ecr
aws ecr get-login-password --profile <aws_profile> --region <aws_region> | docker login --username AWS --password-stdin <ecr_repo_url>
# build tag and push image to ecr
docker buildx build --platform linux/arm64 --provenance=false -t <ecr_repo_url>:<image_tag> --push .

Delete S3 and ECR

# delete ecr
aws ecr delete-repository --repository-name <ecr_repo_name> --force --profile <aws_profile> --region <aws_region>

References

About

deploying aws lambda function using zip and docker with terraform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published