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

Support AWS Provider V5 #284

Merged
merged 61 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2e49c0c
Support AWS Provider V5
max-lobur Jun 9, 2023
b0a2cf9
Update versions.tf
max-lobur Jun 9, 2023
4e2aa16
Update versions.tf
max-lobur Jun 9, 2023
5defc73
Update versions.tf
max-lobur Jun 9, 2023
8c19840
Support AWS Provider V5
max-lobur Jun 9, 2023
a60cbca
bump provider
max-lobur Jun 9, 2023
986ed62
Support AWS Provider V5
max-lobur Jun 9, 2023
d727c1d
Support AWS Provider V5
max-lobur Jun 12, 2023
7310e5a
Support AWS Provider V5
max-lobur Jun 12, 2023
ff3c350
Support AWS Provider V5
max-lobur Jun 12, 2023
2b17944
upd
max-lobur Jun 12, 2023
acfcb1c
upd
max-lobur Jun 12, 2023
ac6a5c2
upd
max-lobur Jun 12, 2023
d860845
upd
max-lobur Jun 12, 2023
b78448c
upd
max-lobur Jun 12, 2023
2909451
upd
max-lobur Jun 13, 2023
2c08980
upd
max-lobur Jun 13, 2023
db53c0a
upd
max-lobur Jun 13, 2023
191cf0c
upd
max-lobur Jun 13, 2023
44814db
upd
max-lobur Jun 13, 2023
ac8e3b5
upd
max-lobur Jun 13, 2023
96ecf5c
upd
max-lobur Jun 14, 2023
e202fd3
upd
max-lobur Jun 15, 2023
be8070a
Add policy
max-lobur Jun 28, 2023
05bf010
use ACL for logging s3-bucket access
milldr Jul 21, 2023
3e018a7
make readme
milldr Jul 21, 2023
d2f8bd2
Removed unused locals, use updated bucket acl pattern, enable logging…
milldr Jul 21, 2023
7d199c6
allow public policy for test bucket
milldr Jul 21, 2023
8d4e13b
tf fmt
milldr Jul 21, 2023
56caadc
set BucketOwnerEnforced
milldr Jul 22, 2023
398d547
set acl with string, not grant
milldr Jul 22, 2023
26bf579
set logs ownership to ObjectWriter
milldr Jul 22, 2023
c5f58dd
set s3_object_ownership for test buckets
milldr Jul 22, 2023
257edbe
set logs bucket to BucketOwnerPreferred
milldr Jul 22, 2023
f411f16
Set bucket-owner-full-control
milldr Jul 22, 2023
2b8758f
reset to grant
milldr Jul 22, 2023
fc18f7a
Update main.tf
milldr Jul 22, 2023
bb34f28
set log-delivery-write for test bucekts
milldr Jul 22, 2023
7f5a8b4
set ownership on test bucket
milldr Jul 22, 2023
5028c8d
set BucketOwnerPreferred with grant list for test buckets
milldr Jul 22, 2023
d8a3fb5
reset tests, set ownership to BucketOwnerPreferred
milldr Jul 22, 2023
6dc01b4
setting s3_object_ownership
milldr Jul 22, 2023
c80947f
dependency for bucket settings before cdn
milldr Jul 22, 2023
9b99d12
Update examples/complete/main.tf
milldr Jul 22, 2023
bcef6a2
dependency for tweaks
milldr Jul 22, 2023
52c9da3
added more wait ons for bucket settings
milldr Jul 22, 2023
ba4ea46
added more wait ons for bucket settings
milldr Jul 22, 2023
9777e27
set ownership on test bucket, set acl null of s3
milldr Jul 22, 2023
2d2a3c0
set BucketOwnerEnforced
milldr Jul 22, 2023
550676d
set grants
milldr Jul 22, 2023
4f2ab30
set grants
milldr Jul 22, 2023
dbc01c9
Set policy after bucket settings
milldr Jul 24, 2023
9308ec6
Set block_origin_public_access_enabled
milldr Jul 24, 2023
8001efe
revert s3-origins test
milldr Jul 24, 2023
757e244
set BucketOwnerEnforced
milldr Jul 24, 2023
e4f44e4
sleep for eventual consistency
milldr Jul 24, 2023
a99c9ce
Set acl for s3-origin tests
milldr Jul 24, 2023
4ce087f
replace s3-website module with s3-bucket for tests
milldr Jul 25, 2023
68917e2
corrected bucket name input
milldr Jul 25, 2023
38463b6
corrected bucket name input
milldr Jul 25, 2023
c0e1360
bridgecrew issues resolved
milldr Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'docs/**'
- 'examples/**'
- 'test/**'
- 'README.*'

permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ permissions:

jobs:
terraform-module:
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release.yml@main
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release-published.yml@main
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,15 @@ Available targets:
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.64.0, != 4.0.0, != 4.1.0, != 4.2.0, != 4.3.0, != 4.4.0, != 4.5.0, != 4.6.0, != 4.7.0, != 4.8.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.2 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.7 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.64.0, != 4.0.0, != 4.1.0, != 4.2.0, != 4.3.0, != 4.4.0, != 4.5.0, != 4.6.0, != 4.7.0, != 4.8.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.2 |
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.7 |

Expand All @@ -453,7 +453,7 @@ Available targets:
| Name | Source | Version |
|------|--------|---------|
| <a name="module_dns"></a> [dns](#module\_dns) | cloudposse/route53-alias/aws | 0.13.0 |
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 0.26.0 |
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 1.4.0 |
| <a name="module_origin_label"></a> [origin\_label](#module\_origin\_label) | cloudposse/label/null | 0.25.0 |
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |

Expand Down
6 changes: 3 additions & 3 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.64.0, != 4.0.0, != 4.1.0, != 4.2.0, != 4.3.0, != 4.4.0, != 4.5.0, != 4.6.0, != 4.7.0, != 4.8.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.2 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.7 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.64.0, != 4.0.0, != 4.1.0, != 4.2.0, != 4.3.0, != 4.4.0, != 4.5.0, != 4.6.0, != 4.7.0, != 4.8.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.2 |
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.7 |

Expand All @@ -21,7 +21,7 @@
| Name | Source | Version |
|------|--------|---------|
| <a name="module_dns"></a> [dns](#module\_dns) | cloudposse/route53-alias/aws | 0.13.0 |
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 0.26.0 |
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 1.4.0 |
| <a name="module_origin_label"></a> [origin\_label](#module\_origin\_label) | cloudposse/label/null | 0.25.0 |
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ locals {
} : {}

our_account_id = local.enabled ? data.aws_caller_identity.current[0].account_id : ""
our_role_arn_prefix = "arn:${join("", data.aws_partition.current.*.partition)}:iam::${local.our_account_id}:role"
our_role_arn_prefix = "arn:${join("", data.aws_partition.current[*].partition)}:iam::${local.our_account_id}:role"
role_names = { for k, v in local.test_deployment_role_prefix_map : k => module.role_labels[k].id }
deployment_principal_arns = { for k, v in local.role_names : format("%v/%v", local.our_role_arn_prefix, v) => local.test_deployment_role_prefix_map[k] }
}
Expand Down
6 changes: 3 additions & 3 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data "aws_iam_policy_document" "document" {

actions = ["s3:GetObject"]
resources = [
"arn:${join("", data.aws_partition.current.*.partition)}:s3:::$${bucket_name}$${origin_path}testprefix/*"
"arn:${join("", data.aws_partition.current[*].partition)}:s3:::$${bucket_name}$${origin_path}testprefix/*"
]

principals {
Expand All @@ -36,7 +36,7 @@ data "aws_canonical_user_id" "current" {

module "s3_bucket" {
source = "cloudposse/s3-bucket/aws"
version = "0.36.0"
version = "3.1.2"

acl = null
force_destroy = true
Expand Down Expand Up @@ -105,7 +105,7 @@ module "cloudfront_s3_cdn" {
context = module.this.context
}

resource "aws_s3_bucket_object" "index" {
resource "aws_s3_object" "index" {
count = local.enabled ? 1 : 0

bucket = module.cloudfront_s3_cdn.s3_bucket
Expand Down
4 changes: 2 additions & 2 deletions examples/complete/s3-origins.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ locals {

module "additional_s3_origin" {
source = "cloudposse/s3-bucket/aws"
version = "0.39.0"
version = "3.1.2"
enabled = local.additional_s3_origins_enabled

acl = "private"
Expand All @@ -43,7 +43,7 @@ module "additional_s3_origin" {

module "additional_s3_failover_origin" {
source = "cloudposse/s3-bucket/aws"
version = "0.39.0"
version = "3.1.2"
enabled = local.additional_s3_origins_enabled

acl = "private"
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/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.0"
version = ">= 5.0"
}
}
}
22 changes: 11 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ resource "random_password" "referer" {
data "aws_iam_policy_document" "s3_origin" {
count = local.s3_origin_enabled ? 1 : 0

override_json = local.override_policy
override_policy_documents = [local.override_policy]

statement {
sid = "S3GetObjectForCloudFront"

actions = ["s3:GetObject"]
resources = ["arn:${join("", data.aws_partition.current.*.partition)}:s3:::${local.bucket}${local.origin_path}*"]
resources = ["arn:${join("", data.aws_partition.current[*].partition)}:s3:::${local.bucket}${local.origin_path}*"]

principals {
type = "AWS"
Expand All @@ -151,7 +151,7 @@ data "aws_iam_policy_document" "s3_origin" {
sid = "S3ListBucketForCloudFront"

actions = ["s3:ListBucket"]
resources = ["arn:${join("", data.aws_partition.current.*.partition)}:s3:::${local.bucket}"]
resources = ["arn:${join("", data.aws_partition.current[*].partition)}:s3:::${local.bucket}"]

principals {
type = "AWS"
Expand All @@ -163,13 +163,13 @@ data "aws_iam_policy_document" "s3_origin" {
data "aws_iam_policy_document" "s3_website_origin" {
count = local.website_enabled ? 1 : 0

override_json = local.override_policy
override_policy_documents = [local.override_policy]

statement {
sid = "S3GetObjectForCloudFront"

actions = ["s3:GetObject"]
resources = ["arn:${join("", data.aws_partition.current.*.partition)}:s3:::${local.bucket}${local.origin_path}*"]
resources = ["arn:${join("", data.aws_partition.current[*].partition)}:s3:::${local.bucket}${local.origin_path}*"]

principals {
type = "AWS"
Expand Down Expand Up @@ -233,9 +233,9 @@ data "aws_iam_policy_document" "combined" {
count = local.enabled ? 1 : 0

source_policy_documents = compact(concat(
data.aws_iam_policy_document.s3_origin.*.json,
data.aws_iam_policy_document.s3_website_origin.*.json,
data.aws_iam_policy_document.s3_ssl_only.*.json,
data.aws_iam_policy_document.s3_origin[*].json,
data.aws_iam_policy_document.s3_website_origin[*].json,
data.aws_iam_policy_document.s3_ssl_only[*].json,
values(data.aws_iam_policy_document.deployment)[*].json
))
}
Expand All @@ -244,7 +244,7 @@ resource "aws_s3_bucket_policy" "default" {
count = local.create_s3_origin_bucket || local.override_origin_bucket_policy ? 1 : 0

bucket = local.origin_bucket.bucket
policy = join("", data.aws_iam_policy_document.combined.*.json)
policy = join("", data.aws_iam_policy_document.combined[*].json)
}

resource "aws_s3_bucket" "origin" {
Expand All @@ -256,7 +256,7 @@ resource "aws_s3_bucket" "origin" {
count = local.create_s3_origin_bucket ? 1 : 0

bucket = module.origin_label.id
acl = "private"
aws_s3_bucket_acl = "private"
tags = module.origin_label.tags
force_destroy = var.origin_force_destroy
max-lobur marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -342,7 +342,7 @@ resource "time_sleep" "wait_for_aws_s3_bucket_settings" {

module "logs" {
source = "cloudposse/s3-log-storage/aws"
version = "0.26.0"
version = "1.4.1"
enabled = local.create_cf_log_bucket
attributes = var.extra_logs_attributes
lifecycle_prefix = local.cloudfront_access_log_prefix
Expand Down
2 changes: 1 addition & 1 deletion modules/lambda@edge/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.0"
version = ">= 5.0"
}
time = {
source = "hashicorp/time"
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ output "cf_identity_iam_arn" {
}

output "cf_origin_groups" {
value = try(flatten(aws_cloudfront_distribution.default.*.origin_group), [])
value = try(flatten(aws_cloudfront_distribution.default[*].origin_group), [])
description = "List of Origin Groups in the CloudFront distribution."
}

Expand All @@ -44,7 +44,7 @@ output "cf_primary_origin_id" {
}

output "cf_origin_ids" {
value = try(aws_cloudfront_distribution.default[0].origin.*.origin_id, [])
value = try(aws_cloudfront_distribution.default[0].origin[*].origin_id, [])
description = "List of Origin IDs in the CloudFront distribution."
}

Expand All @@ -69,7 +69,7 @@ output "s3_bucket_arn" {
}

output "s3_bucket_policy" {
value = join("", aws_s3_bucket_policy.default.*.policy)
value = join("", aws_s3_bucket_policy.default[*].policy)
description = "Final computed S3 bucket policy"
}

Expand Down
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.64.0, != 4.0.0, != 4.1.0, != 4.2.0, != 4.3.0, != 4.4.0, != 4.5.0, != 4.6.0, != 4.7.0, != 4.8.0"
version = ">= 5.0"
}
random = {
source = "hashicorp/random"
Expand Down