Govcloud partition refactor (#235)

This commit is contained in:
Robert Fairburn authored and GitHub committed 2026-05-26 05:18:51 -05:00
1 parent 4763e68d85
commit 95ead0f16d
15 files changed
+61 -13

No files matched your search

+2 -1
View File
@@ -16,6 +16,7 @@ KMS_KEY_ARN = os.environ["KMS_KEY_ARN"]
LOG_PREFIX = os.environ["LOG_PREFIX"]
ACCOUNT_ID = os.environ["ACCOUNT_ID"]
REGION = os.environ["REGION"]
PARTITION = os.environ["PARTITION"]
BATCH_ROLE_ARN = os.environ["BATCH_ROLE_ARN"]
@@ -70,7 +71,7 @@ def handler(event, context):
manifest_etag = put_resp["ETag"]
# Submit S3 Batch Operations job
bucket_arn = f"arn:aws:s3:::{BUCKET}"
bucket_arn = f"arn:{PARTITION}:s3:::{BUCKET}"
job = s3control.create_job(
AccountId=ACCOUNT_ID,
Operation={
+1
View File
@@ -548,6 +548,7 @@ resource "aws_lambda_function" "sweep_reencrypt" {
LOG_PREFIX = local.s3_path_prefix
ACCOUNT_ID = data.aws_caller_identity.current.account_id
REGION = data.aws_region.current.region
PARTITION = data.aws_partition.current.partition
BATCH_ROLE_ARN = aws_iam_role.batch_reencrypt[0].arn
}
}
@@ -65,6 +65,7 @@ sanitize_role_name() {
source_bucket=""
kms_key_arn=""
account_id=""
partition=""
region=""
report_bucket=""
report_prefix="_batch-copy-migration/"
@@ -164,6 +165,8 @@ if [[ -z "$account_id" ]]; then
account_id="$(aws sts get-caller-identity --query 'Account' --output text)"
fi
partition="$(aws sts get-caller-identity --query 'Arn' --output text | cut -d: -f2)"
if [[ -z "$region" && -n "$source_bucket" ]]; then
region="$(aws s3api get-bucket-location --bucket "$source_bucket" --query 'LocationConstraint' --output text)"
if [[ "$region" == "None" ]]; then
@@ -210,7 +213,7 @@ if [[ -z "$batch_role_arn" ]]; then
if [[ -z "$batch_role_name" ]]; then
batch_role_name="$(sanitize_role_name "${source_bucket}-s3-batch-copy")"
fi
batch_role_arn="arn:aws:iam::${account_id}:role/${batch_role_name}"
batch_role_arn="arn:${partition}:iam::${account_id}:role/${batch_role_name}"
elif [[ -z "$batch_role_name" ]]; then
batch_role_name="${batch_role_arn##*/}"
fi
@@ -247,8 +250,8 @@ fi
# ── Build manifest ────────────────────────────────────────────────────────────
source_bucket_arn="arn:aws:s3:::${source_bucket}"
report_bucket_arn="arn:aws:s3:::${report_bucket}"
source_bucket_arn="arn:${partition}:s3:::${source_bucket}"
report_bucket_arn="arn:${partition}:s3:::${report_bucket}"
client_request_token="$(uuidgen | tr '[:upper:]' '[:lower:]')"
tmpdir="$(mktemp -d)"