Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a4b12df
configurable external access to buckets for cross-account
etcart Nov 23, 2025
726b398
Merge branch 'main' into cross-account-access-bucket-config
etcart Nov 24, 2025
bdc39d8
Update daac/policy.tf
etcart Nov 24, 2025
2f303f8
Update daac/policy.tf
etcart Nov 24, 2025
1cc7f9f
Update daac/policy.tf
etcart Nov 24, 2025
9ee223f
Update daac/policy.tf
etcart Nov 24, 2025
1d8ce04
WIP checking on access_point
etcart Nov 24, 2025
e5a2960
moving tenant resources to access point policy
etcart Nov 25, 2025
70d9777
orchestrator and tenant policy deploys
etcart Nov 25, 2025
ab784e0
name change and add default mapping null
etcart Nov 28, 2025
760e0eb
rename for consolidation/legacy scheme
etcart Nov 28, 2025
b02c3f5
fix for iams getting mangeld
etcart Dec 2, 2025
612b986
removing ap stuff
etcart Dec 2, 2025
c38f5e7
some more cleanup
etcart Dec 2, 2025
7f2ebf0
remove policy
etcart Dec 2, 2025
c186cb5
pretty sure this will work
etcart Dec 3, 2025
ca597c9
parsing oai's polciy on top of consolidation policy
etcart Dec 3, 2025
b52f3a3
try for no account ID
etcart Dec 4, 2025
2298e19
Merge branch 'non-ap-cross-acct' into cross-account-access-bucket-config
etcart Dec 4, 2025
45f5458
over to non-ap
etcart Dec 4, 2025
533a0dc
linting
etcart Dec 4, 2025
9b20575
newline
etcart Dec 4, 2025
fda10bd
better multi-policy joining
etcart Dec 8, 2025
aa2cf5f
mistaken reference
etcart Dec 8, 2025
921fe75
fixes
etcart Dec 9, 2025
dc035b6
finally figured out a syntax error
etcart Dec 10, 2025
65ee588
corrected key fo rbucket policy
etcart Dec 10, 2025
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
11 changes: 9 additions & 2 deletions daac/distribution_bucket_policy.tf
Copy link
Contributor

@mattp0 mattp0 Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would structurally be better to instead of manually merging the old distribution policy into your new one is to keep the iam_policy_document approach and rely on the policy document merging you can use https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#example-of-merging-source-documents

This makes it a bit more composable for the users in my opinion and a bit cleaner as far as extending policies in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, that looks much cleaner

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ data "aws_iam_policy_document" "distribution_bucket_policy_document" {
}
}

resource "aws_s3_bucket_policy" "distribution_bucket_policy" {
data "aws_iam_policy_document" "consolidated_distribution_bucket_policy_document" {
for_each = local.distribution_bucket_oais
source_policy_documents = flatten([
data.aws_iam_policy_document.distribution_bucket_policy_document[each.key].json,
try(aws_s3_bucket_policy.allow_crud_from_consolidation["${local.prefix}-${each.key}"].policy, [])
])
}

resource "aws_s3_bucket_policy" "consolidated_distribution_bucket_policy" {
for_each = data.aws_iam_policy_document.consolidated_distribution_bucket_policy_document
bucket = "${local.prefix}-${each.key}"
policy = try(data.aws_iam_policy_document.distribution_bucket_policy_document[each.key].json, null)
policy = each.value.json
}
49 changes: 49 additions & 0 deletions daac/legacy_access_resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
resource "aws_s3_bucket_policy" "allow_crud_from_consolidation" {
for_each = var.consolidation_acct_id != null ? merge(
aws_s3_bucket.public-bucket,
aws_s3_bucket.standard-bucket,
aws_s3_bucket.protected-bucket,
aws_s3_bucket.workflow-bucket
) : {}
bucket = each.key
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Sid = "${each.key}-CrossAccountReadAccess",
Effect = "Allow"
Principal = {
AWS = local.consolidation_crud_roles
},

Action = [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:ListBucket"
],

Resource = [
each.value.arn,
"${each.value.arn}/*"
]
},
{
Sid = "${each.key}-CrossAccountWriteAccess",
Effect = "Allow"
Principal = {
AWS = local.consolidation_crud_roles
},

Action = [
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],

Resource = [
"${each.value.arn}/*"
]
},
]
})
}
7 changes: 6 additions & 1 deletion daac/locals.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
prefix = "${var.DEPLOY_NAME}-cumulus-${var.MATURITY}"

consolidation_maturity = var.consolidation_maturity != null ? var.consolidation_maturity: var.MATURITY
default_tags = {
Deployment = local.prefix
}
Expand Down Expand Up @@ -69,4 +69,9 @@ locals {
local.internal_bucket_map,
local.partner_bucket_map,
)
# consolidation crud acct roles
consolidation_crud_roles = [
var.consolidation_acct_id == null ? null : "arn:aws:iam::${var.consolidation_acct_id}:role/${var.consolidation_deploy_name}-cumulus-${local.consolidation_maturity}_ecs_cluster_instance_role",
var.consolidation_acct_id == null ? null : "arn:aws:iam::${var.consolidation_acct_id}:role/${var.consolidation_deploy_name}-cumulus-${local.consolidation_maturity}-lambda-processing"
]
}
18 changes: 18 additions & 0 deletions daac/variables.tf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing trailing new line on file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline at end of file

Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ variable "s3_replicator_target_prefix" {
default = null
description = "Prefix that the S3 replicator will write logs to in the target bucket."
}

variable "consolidation_acct_id" {
type = string
description = "account id of relevant cumulus consolidation stack"
default = null
}

variable "consolidation_deploy_name" {
type = string
description = "deploy_name of relevant consolidation stack"
default = "willow"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is willow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think id be more in favor of not having a default here. Forgetting to set this resulting in stuff prefixed willow is unintuitive for users of CIRRUS. Probably better to let the TF fail if nothing is provided?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, willow is currently the prefix of the consolidation stack(s)
which got named because I had to stand one up before people had made any decisions
but I can make it non-defaulted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if thats the prefix and its sticking around :D

}

variable "consolidation_maturity" {
type = string
description = "maturity of relevant consolidation stack"
default = null
}