Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1d2546d
ci: setup fork sync
SizZiKe Apr 7, 2022
5c8d6a4
feat(terraform): allow spacelift private modules
SizZiKe Apr 7, 2022
9c87265
feat(aft request): table for unique application names
SizZiKe Apr 7, 2022
17e3a57
feat(spacelift): add prod
SizZiKe Apr 7, 2022
111ddf0
fix(secrets): use ssm key
SizZiKe Apr 7, 2022
615a45c
Merge branch 'aws-ia:main' into main
SizZiKe May 10, 2022
1354d2a
feat(account request): allow account request to use spacelift module …
SizZiKe May 10, 2022
f53bf18
Merge branch 'aws-ia:main' into main
SizZiKe May 16, 2022
51553ec
feat(secrets): centralize
SizZiKe May 16, 2022
c9ea38d
fix(secrets): add caller identity (#14)
SizZiKe May 16, 2022
adc24d8
fix(secrets): use ssm key (#15)
SizZiKe May 16, 2022
f19505d
fix(secrets): use correct provider (#16)
SizZiKe May 16, 2022
0f3e428
feat(secrets): allow global customizations to use spacelift (#17)
SizZiKe May 16, 2022
88c3b6a
Merge branch 'aws-ia:main' into main
SizZiKe May 31, 2022
1416dff
Merge branch 'aws-ia:main' into main
SizZiKe May 31, 2022
12417c9
Merge branch 'aws-ia:main' into main
SizZiKe Jun 13, 2022
dbc894c
Advanced SSM Parameters (#18)
SizZiKe Jun 13, 2022
380a676
feat(pre-api): add mgmt account creds, don't purge (#19)
SizZiKe Jun 14, 2022
6a892bf
Merge remote-tracking branch 'upstream/main'
SizZiKe Jul 5, 2022
599651a
1.5.1
SizZiKe Jul 5, 2022
a1f2dc3
feat(secrets): add nonprod with new key (#21)
SizZiKe Jul 12, 2022
5e832f7
feat(secrets): update terraformrc nonprod (#22)
SizZiKe Jul 12, 2022
440d189
feat(network): add table for shared network
SizZiKe Nov 3, 2022
ad17956
Merge pull request #23 from mondelez-ctiso/feat/shared-networks
SizZiKe Nov 3, 2022
2111c61
feat(network): add configuration, grant tables (#24)
SizZiKe Nov 17, 2022
61fc38d
fixing conflict
cdhesse Feb 1, 2023
53fd59a
Merge pull request #25 from mondelez-ctiso/feat/update_aft
cdhesse Feb 1, 2023
c1a4b53
Merge pull request #26 from aws-ia/main
cdhesse Aug 10, 2023
d20eb1f
fix(delete default vpc): client overwrite (#30)
SizZiKe Mar 1, 2024
e999c11
Release: 1.10.4 (#31)
SizZiKe Mar 1, 2024
404a59b
Merge tag '1.11.1' into feat/1.11.1
SizZiKe Mar 1, 2024
9a32f3e
Merge pull request #32 from mondelez-ctiso/feat/1.11.1
SizZiKe Mar 1, 2024
6ff3dd6
Merge tag '1.12.2'
SizZiKe May 13, 2024
cbbb47b
Merge pull request #33 from mondelez-ctiso/feat/1.12.2
SizZiKe May 13, 2024
ef93779
fix(ddb): remove limits
SizZiKe Oct 22, 2024
2bbf571
feat(account request): moved to spacelift
SizZiKe Oct 22, 2024
d45a33b
Merge pull request #37 from mondelez-ctiso/feat/ddb-limits-remove-cod…
SizZiKe Oct 22, 2024
1ae4792
get DeleteAccount field and selectively run terraform apply or destroy
Nov 7, 2024
d3839cf
get delete account param using ssm
Nov 26, 2024
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
18 changes: 18 additions & 0 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Fork Synchronization
on:
schedule:
- cron: '*/15 * * * *'
workflow_dispatch:
permissions:
pull-requests: write
jobs:
sync:
runs-on: ubuntu-20.04
steps:
- uses: tgymnich/[email protected]
with:
owner: aws-ia
base: main
head: main
retry_after: 10
auto_merge: false
32 changes: 32 additions & 0 deletions MDLZ_ADDITIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Mondelez Modifications to AFT
## Application/Network Request Table
### AFT Enhancement Request
IAM permissions for the ct-aft-codebuild-account-request-role should be able to be supplemented by user input.
### Purpose
To restrict a grouping of accounts to a specific application name that cannot be reused.
### Modifications
- [main.tf](main.tf) passing of value between modules
- [modules/aft-account-request-framework/ddb_custom.tf](modules/aft-account-request-framework/ddb_custom.tf) addition of the DynamoDB table
- [modules/aft-account-request-framework/outputs_custom.tf](modules/aft-account-request-framework/outputs_custom.tf) addition of an output to pass the table name
- [modules/aft-code-repositories/variables.tf](modules/aft-code-repositories/variables.tf) adding a variable to pass the table name to iam
- [modules/aft-code-repositories/iam.tf](modules/aft-code-repositories/iam.tf) passing the table name to an iam template
- [modules/aft-code-repositories/iam/role-policies/ct_aft_codebuild_policy.tpl](modules/aft-code-repositories/iam/role-policies/ct_aft_codebuild_policy.tpl) adding the table to the iam template
## Terraformrc for Private Modules
### AFT Enhancement Request
Commands should be able to be added at the beginning/end of each AFT CodeBuild project build phase.
### Purpose
To allow private module use within the AFT Terraform CodeBuild projects.
### Modifications
- [modules/aft-code-repositories/buildspecs/ct-aft-account-provisioning-customizations.yml](modules/aft-code-repositories/buildspecs/ct-aft-account-provisioning-customizations.yml) retrieve .terraformrc from SSM and save to ~/.terraformrc
- [modules/aft-customizations/buildspecs/aft-account-customizations-terraform.yml](modules/aft-customizations/buildspecs/aft-account-customizations-terraform.yml) retrieve .terraformrc from SSM and save to ~/.terraformrc
- [modules/aft-customizations/buildspecs/aft-global-customizations-terraform.yml](modules/aft-customizations/buildspecs/aft-global-customizations-terraform.yml) retrieve .terraformrc from SSM and save to ~/.terraformrc
- [modules/aft-ssm-parameters/secrets/039570753310/spacelift_terraformrc.enc](modules/aft-ssm-parameters/secrets/039570753310/spacelift_terraformrc.enc) added encrypted .terraformrc to repo
- [modules/aft-ssm-parameters/data_custom.tf](modules/aft-ssm-parameters/data.tf) added decryption for the .terraformrc
- [modules/aft-ssm-parameters/ssm_secrets_custom.tf](modules/aft-ssm-parameters/ssm_secrets.tf) added the SSM secret

## Secrets
### Purpose
To enable AFT to leverage custom secrets.
### Modifications
- [data_custom.tf](data.tf) decryption of the secrets
- [ssm_custom.tf](ssm_custom.tf) added the SSM secrets
22 changes: 22 additions & 0 deletions data_custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
data "aws_caller_identity" "aft_management" {
provider = aws.aft_management
}

data "aws_kms_secrets" "mondelez" {
provider = aws.aft_management
secret {
name = "github_app_private_key"
payload = file("${path.module}/secrets/${data.aws_caller_identity.aft_management.account_id}/github-app-private-key.pem.enc")
context = {
AccountID = data.aws_caller_identity.aft_management.account_id
}
}

secret {
name = "spacelift_api_key"
payload = file("${path.module}/secrets/${data.aws_caller_identity.aft_management.account_id}/spacelift-api-key.enc")
context = {
AccountID = data.aws_caller_identity.aft_management.account_id
}
}
}
6 changes: 6 additions & 0 deletions locals_custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
locals {
ssm_paths_custom = {
spacelift_api_credentials = "/aft/config/spacelift/api-credentials"
github_app_credentials = "/aft/config/github/app-credentials"
}
}
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ module "aft_code_repositories" {
aft_config_backend_table_id = module.aft_backend.table_id
aft_config_backend_kms_key_id = module.aft_backend.kms_key_id
account_request_table_name = module.aft_account_request_framework.request_table_name
application_request_table_arn = module.aft_account_request_framework.application_request_table_arn # MDLZ CUSTOMIZATION
network_request_configuration_table_arn = module.aft_account_request_framework.network_request_configuration_table_arn # MDLZ CUSTOMIZATION
network_request_grant_table_arn = module.aft_account_request_framework.network_request_grant_table_arn # MDLZ CUSTOMIZATION
codepipeline_s3_bucket_arn = module.aft_customizations.aft_codepipeline_customizations_bucket_arn
codepipeline_s3_bucket_name = module.aft_customizations.aft_codepipeline_customizations_bucket_name
security_group_ids = module.aft_account_request_framework.aft_vpc_default_sg
Expand Down Expand Up @@ -135,6 +138,7 @@ module "aft_customizations" {
global_codebuild_timeout = var.global_codebuild_timeout
lambda_runtime_python_version = local.lambda_runtime_python_version
aft_enable_vpc = var.aft_enable_vpc
spacelift_api_credentials_ssm_path = local.ssm_paths_custom.spacelift_api_credentials
}

module "aft_feature_options" {
Expand Down
16 changes: 6 additions & 10 deletions modules/aft-account-request-framework/ddb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
#
# Table that stores account-meta data
resource "aws_dynamodb_table" "aft_request_metadata" {
name = "aft-request-metadata"
read_capacity = 1
write_capacity = 1
hash_key = "id"
name = "aft-request-metadata"
hash_key = "id"
billing_mode = "PAY_PER_REQUEST"

attribute {
name = "id"
Expand Down Expand Up @@ -53,8 +52,7 @@ resource "aws_dynamodb_table" "aft_request_metadata" {
# Table that stores the configuration details for the account vending machine
resource "aws_dynamodb_table" "aft_request" {
name = "aft-request"
read_capacity = 1
write_capacity = 1
billing_mode = "PAY_PER_REQUEST"
hash_key = "id"
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
Expand All @@ -77,8 +75,7 @@ resource "aws_dynamodb_table" "aft_request" {
# Table that stores the audit history for the account
resource "aws_dynamodb_table" "aft_request_audit" {
name = "aft-request-audit"
read_capacity = 1
write_capacity = 1
billing_mode = "PAY_PER_REQUEST"
hash_key = "id"
range_key = "timestamp"
stream_enabled = true
Expand Down Expand Up @@ -107,8 +104,7 @@ resource "aws_dynamodb_table" "aft_request_audit" {
# Table that stores the audit history for the account
resource "aws_dynamodb_table" "aft_controltower_events" {
name = "aft-controltower-events"
read_capacity = 5
write_capacity = 5
billing_mode = "PAY_PER_REQUEST"
hash_key = "id"
range_key = "time"
stream_enabled = true
Expand Down
70 changes: 70 additions & 0 deletions modules/aft-account-request-framework/ddb_custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# MDLZ CUSTOMIZATION
resource "aws_dynamodb_table" "aft_application_request" {
name = "aft-application-request"
read_capacity = 1
write_capacity = 1
hash_key = "ApplicationName"

attribute {
name = "ApplicationName"
type = "S"
}

point_in_time_recovery {
enabled = true
}

server_side_encryption {
enabled = true
kms_key_arn = aws_kms_key.aft.arn
}
}

# MDLZ CUSTOMIZATION
resource "aws_dynamodb_table" "aft_network_request_configuration" {
name = "aft-network-request-configuration"
read_capacity = 1
write_capacity = 1
hash_key = "NetworkName"

attribute {
name = "NetworkName"
type = "S"
}

point_in_time_recovery {
enabled = true
}

server_side_encryption {
enabled = true
kms_key_arn = aws_kms_key.aft.arn
}
}

resource "aws_dynamodb_table" "aft_network_request_grant" {
name = "aft-network-request-grant"
read_capacity = 1
write_capacity = 1
hash_key = "NetworkName"
range_key = "AccountSlug"

attribute {
name = "NetworkName"
type = "S"
}

attribute {
name = "AccountSlug"
type = "S"
}

point_in_time_recovery {
enabled = true
}

server_side_encryption {
enabled = true
kms_key_arn = aws_kms_key.aft.arn
}
}
14 changes: 14 additions & 0 deletions modules/aft-account-request-framework/outputs_custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MDLZ CUSTOMIZTAION
output "application_request_table_arn" {
value = aws_dynamodb_table.aft_application_request.arn
}

# MDLZ CUSTOMIZTAION
output "network_request_configuration_table_arn" {
value = aws_dynamodb_table.aft_network_request_configuration.arn
}

# MDLZ CUSTOMIZTAION
output "network_request_grant_table_arn" {
value = aws_dynamodb_table.aft_network_request_grant.arn
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ phases:
- AFT_ADMIN_ROLE_NAME=$(aws ssm get-parameter --name /aft/resources/iam/aft-administrator-role-name | jq --raw-output ".Parameter.Value")
- AFT_ADMIN_ROLE_ARN=arn:$AWS_PARTITION:iam::$AFT_MGMT_ACCOUNT:role/$AFT_ADMIN_ROLE_NAME
- ROLE_SESSION_NAME=$(aws ssm get-parameter --name /aft/resources/iam/aft-session-name | jq --raw-output ".Parameter.Value")
- aws ssm get-parameter --name /aft/config/terraform/spacelift-terraformrc --with-decryption | jq --raw-output ".Parameter.Value" > ~/.terraformrc
- |
ssh_key_parameter=$(aws ssm get-parameter --name /aft/config/aft-ssh-key --with-decryption 2> /dev/null || echo "None")
if [[ $ssh_key_parameter != "None" ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ phases:
- AFT_ADMIN_ROLE_NAME=$(aws ssm get-parameter --name /aft/resources/iam/aft-administrator-role-name | jq --raw-output ".Parameter.Value")
- AFT_ADMIN_ROLE_ARN=arn:$AWS_PARTITION:iam::$AFT_MGMT_ACCOUNT:role/$AFT_ADMIN_ROLE_NAME
- ROLE_SESSION_NAME=$(aws ssm get-parameter --name /aft/resources/iam/aft-session-name | jq --raw-output ".Parameter.Value")
- aws ssm get-parameter --name /aft/config/terraform/spacelift-terraformrc --with-decryption | jq --raw-output ".Parameter.Value" > ~/.terraformrc
- |
ssh_key_parameter=$(aws ssm get-parameter --name /aft/config/aft-ssh-key --with-decryption 2> /dev/null || echo "None")
if [[ $ssh_key_parameter != "None" ]]; then
Expand Down
55 changes: 0 additions & 55 deletions modules/aft-code-repositories/codebuild.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,6 @@ data "local_file" "account_provisioning_customizations_buildspec" {
filename = "${path.module}/buildspecs/ct-aft-account-provisioning-customizations.yml"
}

resource "aws_codebuild_project" "account_request" {
depends_on = [aws_cloudwatch_log_group.account_request, time_sleep.iam_eventual_consistency]
name = "ct-aft-account-request"
description = "Job to apply Terraform for Account Requests"
build_timeout = tostring(var.global_codebuild_timeout)
service_role = aws_iam_role.account_request_codebuild_role.arn
encryption_key = var.aft_key_arn

artifacts {
type = "CODEPIPELINE"
}

environment {
compute_type = "BUILD_GENERAL1_MEDIUM"
image = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
environment_variable {
name = "AWS_PARTITION"
value = data.aws_partition.current.partition
type = "PLAINTEXT"
}
}

logs_config {
cloudwatch_logs {
group_name = aws_cloudwatch_log_group.account_request.name
}

s3_logs {
status = "ENABLED"
location = "${var.codepipeline_s3_bucket_name}/ct-aft-account-request-logs"
}
}

source {
type = "CODEPIPELINE"
buildspec = data.local_file.account_request_buildspec.content
}

dynamic "vpc_config" {
for_each = var.aft_enable_vpc ? [1] : []
content {
vpc_id = var.vpc_id
subnets = var.subnet_ids
security_group_ids = var.security_group_ids
}
}

lifecycle {
ignore_changes = [project_visibility]
}

}

resource "aws_codebuild_project" "account_provisioning_customizations_pipeline" {
depends_on = [aws_cloudwatch_log_group.account_request, time_sleep.iam_eventual_consistency]
name = "ct-aft-account-provisioning-customizations"
Expand Down
Loading