Skip to content

Commit

Permalink
Configuration of the Amazon S3 notification module.
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromoreirati committed Feb 25, 2020
1 parent 10bcd30 commit d237bbf
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 0 deletions.
Binary file added examples/bucket-object/README.md
Binary file not shown.
41 changes: 41 additions & 0 deletions examples/bucket-object/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
provider "aws" {
region = var.region
profile = var.profile
}

module "bucket" {
source = "../../bucket/modules/bucket"

name = "${var.my_team}-${var.product}"
acl = var.acl

versioning = var.versioning

tags = {
Name = "${var.my_team}-${var.product}-${var.environment}"
environment = var.environment
Terraform = "true"
}
}

module "bucket_object" {
source = "../../bucket/modules/bucket-object"

bucket_name = module.bucket.bucket_id
object_key = test.txt
object_source = archive / test.txt

tags = {
Name = "${var.my_team}-${var.product}-${var.environment}"
environment = var.environment
Terraform = "true"
}
}

terraform {
backend "s3" {
bucket = "lms-infraestrutura-terraform"
key = "s3_tecnologia.tfstate"
region = "us-east-1"
}
}
21 changes: 21 additions & 0 deletions examples/bucket-object/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
output "bucket_object_id" {
value = module.bucket_object.bucket_object_id
description = "Name of the bucket to put the file in."
}

output "bucket_object_etag" {
value = module.bucket_object.bucket_object_etag
description = "Name of the bucket to put the file in."
}

output "bucket_id" {
value = module.bucket.bucket_id
description = "Name of the bucket."
}

output "bucket_arn" {
value = module.bucket.bucket_arn
description = "ARN of the bucket."
}


Binary file added modules/bucket-object/README.md
Binary file not shown.
22 changes: 22 additions & 0 deletions modules/bucket-object/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* For more details on the configuration, visit the official documentation::
https://www.terraform.io/docs/providers/aws/r/s3_bucket_object.html
*/

locals {
files_list = [
"${md5(file("${path.module}/main.tf"))}",
"${md5(file("${path.module}/outputs.tf"))}",
"${md5(file("${path.module}/variables.tf"))}",
]
current_deployment = join("", local.files_list)
}

resource "aws_s3_bucket_object" "bucket_object" {

bucket = var.bucket_name
key = var.object_key
source = var.object_source
etag = filemd5(var.object_source)

tags = var.tags
}
10 changes: 10 additions & 0 deletions modules/bucket-object/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
output "bucket_object_id" {
value = aws_s3_bucket_object.bucket_object.*.id
description = "Key of the resource supplied above."
}

output "bucket_object_etag" {
value = aws_s3_bucket_object.bucket_object.*.etag
description = "ETag generated for the object (an MD5 sum of the object content)."
}

24 changes: 24 additions & 0 deletions modules/bucket-object/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
variable "name" {
default = ""
description = "Bucket S3 name."
}

variable "tags" {
type = map(string)
default = {}
}

variable "object_key" {
default = ""
description = "The name of the object once it is in the bucket."
}

variable "object_source" {
default = ""
description = "Path to a file that will be read and uploaded as raw bytes for the object content."
}

variable "bucket_name" {
default = ""
description = "Name of bucket."
}
4 changes: 4 additions & 0 deletions modules/bucket-object/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}

0 comments on commit d237bbf

Please sign in to comment.