These steps are currently impossible in cloudformation without a lot of hoop jumping.
- Log in as root, set strong password and turn on MFA for the root account
- Turn on 'block public access' in S3 at the account level (cloudformation issue: aws-cloudformation/cloudformation-coverage-roadmap#168)
- Deactivate unused STS regions in IAM / account settings
- Create access keys for root
- Bootstrap account for CDK
npx cdk bootstrap --bootstrap-kms-key-id AWS_MANAGED_KEY --profile [aws profile name] aws://[account id]/eu-west-2
- Run:
npx cdk deploy AllAccountsStack --profile [aws profile name]
- Verify users have been created by stack
- Update bootstap:
npx cdk bootstrap --cloudformation-execution-policies "arn:aws:iam::[account id]:policy/developerPolicy" --bootstrap-kms-key-id AWS_MANAGED_KEY --profile [aws profile name] aws://[account id]/eu-west-2
- Update password policy (due to aws-cloudformation/cloudformation-coverage-roadmap#107):
aws iam update-account-password-policy \ --minimum-password-length 50 \ --require-symbols \ --require-numbers \ --require-uppercase-characters \ --require-lowercase-characters \ --no-allow-users-to-change-password \ --password-reuse-prevention 24
- Delete root account keys
- Run tools/delete-vpcs.sh
- Add account number to the list of accounts in the
ChildAccounts
parameter in the parent-account stack
- Turn on billing access via IAM - https://console.aws.amazon.com/billing/home?#/account / IAM User and Role Access to Billing Information / Edit / Activate IAM Access / Update
- Run:
aws ce update-cost-allocation-tags-status --cost-allocation-tags-status TagKey=aws_cloudformation_stack-name,Status=Active
- Run:
aws organizations enable-aws-service-access --service-principal cloudtrail.amazonaws.com
- Run:
aws cloudtrail create-trail --name all-accounts-management-events --s3-bucket-name ${CloudTrailLogsBucket} --is-organization-trail --is-multi-region-trail
( IsOrganizationTrail not supported by cloudformation yet so have to use cli, see aws-cloudformation/cloudformation-coverage-roadmap#45) - Run:
aws cloudtrail start-logging --name all-accounts-management-events