Skip to content

Commit

Permalink
Merge pull request #34 from controlshift/aws_4
Browse files Browse the repository at this point in the history
Migrate resources to Terraform's AWS provider v4
  • Loading branch information
anero authored Mar 25, 2022
2 parents 675cd35 + 2330b68 commit c906074
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
21 changes: 13 additions & 8 deletions glue_job.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ resource "aws_glue_crawler" "signatures_crawler" {

resource "aws_s3_bucket" "glue_resources" {
bucket = var.glue_scripts_bucket_name
region = var.aws_region
}

acl = "private"
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
resource "aws_s3_bucket_acl" "glue_resources" {
bucket = aws_s3_bucket.glue_resources.id
acl = "private"
}

resource "aws_s3_bucket_server_side_encryption_configuration" "glue_resources" {
bucket = aws_s3_bucket.glue_resources.bucket

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
Expand All @@ -40,7 +45,7 @@ data "template_file" "signatures_script" {
}
}

resource "aws_s3_bucket_object" "signatures_script" {
resource "aws_s3_object" "signatures_script" {
bucket = aws_s3_bucket.glue_resources.id
key = "${var.controlshift_environment}/signatures_job.py"
acl = "private"
Expand Down
32 changes: 20 additions & 12 deletions s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,38 @@ provider "aws" {
resource "aws_s3_bucket" "manifest" {
provider = aws.controlshift
bucket = var.manifest_bucket_name
acl = "private"
region = var.controlshift_aws_region

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
tags = {
Name = "ControlShift puts import manifests here"
}
}

resource "aws_s3_bucket_lifecycle_configuration" "manifest" {
bucket = aws_s3_bucket.manifest.id

# expire the ingested manifests after 5 days after they have been processed to save disk space while providing enough
# time to analyze things that might have gone wrong.
lifecycle_rule {
id = "expire-manifests"
enabled = true
rule {
id = "expire-manifests"
status = "Enabled"

expiration {
days = 5
}
}
}

resource "aws_s3_bucket_acl" "manifest" {
bucket = aws_s3_bucket.manifest.id
acl = "private"
}

resource "aws_s3_bucket_server_side_encryption_configuration" "manifest" {
bucket = aws_s3_bucket.manifest.bucket

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
aws = {
source = "hashicorp/aws"
version = "~> 2.0"
version = "~> 4.0"
}
http = {
source = "hashicorp/http"
Expand Down

0 comments on commit c906074

Please sign in to comment.