This file contains 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
# Docs: https://www.terraform.io/docs/providers/aws/r/s3_bucket.html | |
resource "aws_s3_bucket" "bucket-identifier" { | |
bucket = "my-test-bucket" | |
acl = "private" | |
tags = { | |
Name = "A test bucket" | |
} | |
} |
This file contains 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
$ terraform plan | |
... | |
+ aws_s3_bucket.bucket-identifier | |
id: <computed> | |
acceleration_status: <computed> | |
acl: "private" | |
arn: <computed> | |
bucket: "my-test-bucket" | |
bucket_domain_name: <computed> | |
bucket_regional_domain_name: <computed> |
This file contains 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
# resource | |
"${aws_s3_bucket.bucket-identifier}" | |
# data source | |
"${data.aws_s3_bucket.bucket-identifier}" |
This file contains 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
data "aws_s3_bucket" "bucket-identifier" { | |
bucket = "bucket-name" | |
} |
This file contains 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
/src | |
/.terraform | |
- archive.tf | |
- iam.tf | |
- lambda.tf | |
- main.tf | |
- push_to_bucket_1.py | |
- push_to_bucket_2.py | |
- s3.tf | |
- sns.tf |
This file contains 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
provider "aws" { | |
version = "~> 1.26.0" | |
} |
This file contains 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
export AWS_ACCESS_KEY_ID="ACCESS_KEY" | |
export AWS_SECRET_ACCESS_KEY="SECRET" | |
export AWS_DEFAULT_REGION="REGION" |
This file contains 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
# S3 bucket names should not contain numbers or underscores | |
resource "aws_s3_bucket" "source-bucket" { | |
bucket = "source-bucket" | |
acl = "private" | |
tags = { | |
Name = "Source bucket" | |
} | |
} |
This file contains 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
data "aws_iam_policy_document" "sns_policy" { | |
statement { | |
effect = "Allow" | |
principals { | |
identifiers = ["*"] | |
type = "AWS" | |
} | |
actions = [ |
This file contains 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
# ... | |
resource "aws_s3_bucket_notification" "object_create_sns" { | |
bucket = "${aws_s3_bucket.source-bucket.id}" | |
topic { | |
topic_arn = "${aws_sns_topic.s3_fanout.arn}" | |
events = ["s3:ObjectCreated:*"] | |
} | |
} |
OlderNewer