Last active
November 24, 2019 06:57
-
-
Save ashwiniag/adbf3a5925cdd7c5d94f9a7175e5e170 to your computer and use it in GitHub Desktop.
Create S3 bucket and ECR repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Use aws provider and IAM User "name" | |
| provider "aws" { | |
| profile = "name" | |
| region = "eu-west-2" | |
| } | |
| // | |
| ############################################################## | |
| # Create S3 input bucket for storing application in zip format. | |
| ############################################################## | |
| resource "aws_s3_bucket" "input_bucket-test" { | |
| bucket = "codebuild-eu-west-2-input-bucket-test" | |
| acl = "private" | |
| versioning { | |
| enabled = true | |
| } | |
| tags = { | |
| Name = "input_bucket_test" | |
| } | |
| } | |
| ############################################################## | |
| # Create S3 output bucket for storing artifact produced from | |
| #codebuild. | |
| ############################################################## | |
| resource "aws_s3_bucket" "output_bucket-test" { | |
| bucket = "codebuild-eu-west-2-output-bucket-test" | |
| acl = "private" | |
| versioning { | |
| enabled = true | |
| } | |
| tags = { | |
| Name = "output_bucket_test" | |
| } | |
| } | |
| ############################################################# | |
| #Upload zipped code (object) into input bucket for codebuild | |
| #to use it. | |
| ############################################################## | |
| resource "aws_s3_bucket_object" "object" { | |
| bucket = "${aws_s3_bucket.input_bucket-test.id}" | |
| key = "filename.zip" | |
| source = "/path/to/file/filename.zip" | |
| } | |
| ############################################################## | |
| # Create ECR repository to store Docker image build in codebuild | |
| ############################################################## | |
| resource "aws_ecr_repository" "ecr_repo" { | |
| name = "Repo_name" | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://ashwiniag.com for explanation