Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support AWS 4.x Terraform provider #1739

Merged
7 changes: 4 additions & 3 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Verify module
strategy:
matrix:
terraform: [1.1.3, 'latest']
terraform: [1.1.3, "latest"]
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
Expand Down Expand Up @@ -44,8 +44,9 @@ jobs:
strategy:
fail-fast: false
matrix:
terraform: [1.0.11, 1.1.3, 'latest']
example: ["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
terraform: [1.0.11, 1.1.3, "latest"]
example:
["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
defaults:
run:
working-directory: examples/${{ matrix.example }}
Expand Down
2 changes: 1 addition & 1 deletion examples/arm64/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.27"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion examples/default/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.71"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion examples/ephemeral/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.71"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion examples/prebuilt/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.71"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion examples/ubuntu/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.71"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.71"
version = "~> 4.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion modules/download-lambda/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
63 changes: 37 additions & 26 deletions modules/runner-binaries-syncer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,55 @@ locals {

resource "aws_s3_bucket" "action_dist" {
bucket = var.distribution_bucket_name
acl = "private"
force_destroy = true
tags = var.tags
}

# Max 1 block - server_side_encryption_configuration
dynamic "server_side_encryption_configuration" {
for_each = length(keys(var.server_side_encryption_configuration)) == 0 ? [] : [var.server_side_encryption_configuration]

content {

dynamic "rule" {
for_each = length(keys(lookup(server_side_encryption_configuration.value, "rule", {}))) == 0 ? [] : [lookup(server_side_encryption_configuration.value, "rule", {})]
resource "aws_s3_bucket_acl" "action_dist_acl" {
bucket = aws_s3_bucket.action_dist.id
acl = "private"
}

content {
bucket_key_enabled = lookup(rule.value, "bucket_key_enabled", null)
resource "aws_s3_bucket_lifecycle_configuration" "bucket-config" {
bucket = aws_s3_bucket.action_dist.id

dynamic "apply_server_side_encryption_by_default" {
for_each = length(keys(lookup(rule.value, "apply_server_side_encryption_by_default", {}))) == 0 ? [] : [
lookup(rule.value, "apply_server_side_encryption_by_default", {})]
rule {
id = "lifecycle_config"
status = "Enabled"

content {
sse_algorithm = apply_server_side_encryption_by_default.value.sse_algorithm
kms_master_key_id = lookup(apply_server_side_encryption_by_default.value, "kms_master_key_id", null)
}
}
}
}
abort_incomplete_multipart_upload {
days_after_initiation = 7
}
}

lifecycle_rule {
enabled = true
abort_incomplete_multipart_upload_days = 7

transition {
days = 35
storage_class = "INTELLIGENT_TIERING"
}


}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "action_dist" {
bucket = aws_s3_bucket.action_dist.id
count = length(keys(lookup(var.server_side_encryption_configuration, "rule", {}))) == 0 ? 0 : 1

dynamic "rule" {
for_each = [lookup(var.server_side_encryption_configuration, "rule", {})]

content {
bucket_key_enabled = lookup(rule.value, "bucket_key_enabled", null)

dynamic "apply_server_side_encryption_by_default" {
for_each = length(keys(lookup(rule.value, "apply_server_side_encryption_by_default", {}))) == 0 ? [] : [
lookup(rule.value, "apply_server_side_encryption_by_default", {})]

content {
sse_algorithm = apply_server_side_encryption_by_default.value.sse_algorithm
kms_master_key_id = lookup(apply_server_side_encryption_by_default.value, "kms_master_key_id", null)
}
}
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions modules/runner-binaries-syncer/runner-binaries-syncer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ resource "aws_lambda_permission" "syncer" {
### Extra trigger to trigger from S3 to execute the lambda after first deployment
###################################################################################

resource "aws_s3_bucket_object" "trigger" {
bucket = aws_s3_bucket.action_dist.id
key = "triggers/${aws_lambda_function.syncer.id}-trigger.json"
source = "${path.module}/trigger.json"
source_hash = filemd5("${path.module}/trigger.json")
resource "aws_s3_object" "trigger" {
bucket = aws_s3_bucket.action_dist.id
key = "triggers/${aws_lambda_function.syncer.id}-trigger.json"
source = "${path.module}/trigger.json"
etag = filemd5("${path.module}/trigger.json")

depends_on = [aws_s3_bucket_notification.on_deploy]
}
Expand Down
2 changes: 1 addition & 1 deletion modules/runner-binaries-syncer/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/runners/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/setup-iam-permissions/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/ssm/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/webhook/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.38"
version = "~> 4.0"
}
}
}