
In the last post we went over the overall goals of "The Stack" and what we will be building. In this post we'll be setting up our AWS Account structure. See the full overview of posts here.
As a reminder, here is the structure we are aiming for:
Or, for the visual learners:
graph TD
subgraph ControlTower[AWS: Control Tower]
AuditLog[Audit Log]
GuardRails[Guard Rails]
end
ControlTower-->AWSProdMultiTenantAccount
ControlTower-->AWSProdSingleTenantAccount
ControlTower-->AWSIntegrationTestAccount
ControlTower-->AWSPreviewAccount
ControlTower-->AWSIndividualDeveloperAccount
ControlTower-->AWSMonitoringAccount
ControlTower-->AWSLogsAccount
subgraph AWSProdMultiTenantAccount[AWS: Production Multi-tenant]
AccountFillerProdMultiTenant[...]
end
subgraph AWSProdSingleTenantAccount[AWS: Production Single-tenant]
AccountFillerProdSingleTenant[...]
end
subgraph AWSIntegrationTestAccount[AWS: Integration Test]
AccountFillerIntegrationTest[...]
end
subgraph AWSPreviewAccount[AWS: Preview]
AccountFillerPreview[...]
end
subgraph AWSIndividualDeveloperAccount[AWS: Individual Developer]
AccountFillerIndividualDeveloper[...]
end
subgraph AWSMonitoringAccount[AWS: Monitoring]
direction LR
CloudWatchDashboards[CloudWatch Dashboards]
CloudWatchMetrics[CloudWatch Metrics/Alarms]
XRay[XRay Analytics]
end
subgraph AWSLogsAccount[AWS: Logs]
CloudWatchLogs[CloudWatch Logs]
end
classDef container stroke:#333,stroke-width:2px,fill:transparent,padding:8px
class ControlTower,AWSProdMultiTenantAccount,AWSProdSingleTenantAccount,AWSIntegrationTestAccount,AWSPreviewAccount,AWSIndividualDeveloperAccount,AWSMonitoringAccount,AWSLogsAccount container;
Let's jump into it!
AWS has an excellent Getting Started Guide which goes through setting up a new Control Tower at a high-level. We'll do a few adjustments to the defaults to make it fit our needs.
Fist off, you will need an existing AWS Account. This is the one we are turning into our Control Tower, or also called our "Landing Zone". If you don't already have an account ready to use, then go setup your AWS Account first.
Now that we are ready, a high-level overview of the steps we will be taking are:
The first screen you'll meet wants you to review various infomration and pricing as well as choose a few defaults. We are going to change some of the values:
Enabled for this. We want to make sure that Control Tower is governing our accounts and resources.us-east-1 for certain "global" resources, so we'll add that to the list of allowed regions along with your desired region.Now we need to create our Organizational Units (OUs). We want both a Foundation and an Additional OU, but we will rename them a bit to make more sense for our use-case:
Compliance since it contains our Logs as well as our Audit accounts.Production.The Foundation OU, Compliance, creates two accounts for us. We to set up emails for these accounts, but we will keep the names. I recommend pointing this to an administrator email and using + to allow the same email to be used for multiple accounts:
[email protected] (adjust to an account and domain you control)[email protected] (adjust to an account and domain you control)Now that we have a location for our logs, we can configure CloudTrail as well as log retention. You can adjust to your needs, but I recommend the following:
Enabled1 years10 yearsEnable and custome encryption settingsWhen you check the box to enable KMS encryption you'll be asked for a key to use. Click "Create a KMS key" which will take us into the KMS Console:
Key configuration
Key labels
control-tower-cloudtrailKMS key used for CloudTrail logs stored by Control Towerbilling, Value: cloudtrail-control-towerbilling-group, Value: control-towerWe'll immediately start our good habit of adding billing tags whereever we can, which greatly simplifies diving into cloud expenses.
Skip through Step 3, Step 4, and click "Finish" on the review step.
Once the key is created we'll immediately edit it now that it has gotten a Key ID. If we don't we'll run into this nice error later on:
To avoid this:
12345678-1234-1234-1234-123456789012).123456789012).Statement list.Replace AWS_REGION, AWS_ACCOUNT_ID, and KMS_KEY_ID and insert the following:
1 2 3 4 5 6 7 8 9 10 11 12 ,
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
This ensures that both Config and CloudTrail can use the key for encryption and decryption.
Review and confirm the setup.
Finally, we'll also cleanup the VPCs that were created in our Control Tower:
By default the Account Factory will be creating VPCs and Subnets in newly provisioned accounts. We don't want this as we are focusing on serverless, so we'll disable this.
0We've only set up two OUs so far, Compliance and Production, but we have one more we'd like to use. Jump into your Organization overview in Control Tower:
Development and set the Parent OU to Root.This will take a bit of time, and we cannot create accounts during this.
For this step it's important that you are not logged in as the Root user anymore. Instead, jump to your new User portal URL which AWS has set up for us.
Find the User portal URL:
Once you're logged into the Control Tower account using the portal, jump into the Account Factory again:
We'll be creating the following accounts:
Integration Test in our Development OUPreview in our Development OUProduction Multi-tenant in our Production OUProduction Single-tenant in our Production OUMonitoring in our Production OULogs in our Production OUFor each account, in the Create account process, fill in:
[email protected]Integration Test[email protected]IntegrationTestPick the appropriate Organizational unit according to the list above, and click Create account.
You should end up with an overall structure like the following (Preview environment missing, but should be in the Development OU):
Next up, we will be looking at how we can set up and automate our deployments to these environments so that once we start building it will update automatically. Follow along in Part 2 of the series.