Skip to content

Commit 8c3a7ee

Browse files
authored
Merge pull request #84 from aws-samples/bugfix/single-control-tower-region
Single Control Tower region fix
2 parents 6ccf1c9 + bb6f8f4 commit 8c3a7ee

File tree

7 files changed

+38
-17
lines changed

7 files changed

+38
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Table of Contents<!-- omit in toc -->
44

55
- [Introduction](#introduction)
6+
- [2022-03-16](#2022-03-16)
67
- [2022-03-14](#2022-03-14)
78
- [2022-01-07](#2022-01-07)
89
- [2021-12-16](#2021-12-16)
@@ -21,6 +22,12 @@ All notable changes to this project will be documented in this file.
2122

2223
---
2324

25+
## 2022-03-16
26+
27+
### Fixed<!-- omit in toc -->
28+
29+
- Fixed the [Common Prerequisites](aws_sra_examples/solutions/common/common_prerequisites) solution to support Control Tower configurations with a single governed region.
30+
2431
## 2022-03-14
2532

2633
### Added<!-- omit in toc -->

aws_sra_examples/solutions/common/common_prerequisites/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ reference Systems Manager parameters in your scripts, commands, SSM documents, a
5151
- Optional parameters are included to create the parameters in all `member accounts` in the same regions that are enabled in the `management account`.
5252
- This allows for common SSM parameters to be resolved in the `member accounts` for future SRA solutions, and customer workload solutions.
5353
- Common parameters created will be retained even if the CloudFormation stacks from this solution are deleted.
54+
- Empty parameters will get set with `NONE` as the value. For example the '/sra/regions/customer-control-tower-regions-without-home-region' parameter will get set to `NONE` when only one region is governed by Control Tower.
5455

5556
#### 1.6 Staging S3 Bucket<!-- omit in toc -->
5657

aws_sra_examples/solutions/common/common_prerequisites/lambda/src/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"/sra/regions/customer-control-tower-regions-without-home-region",
5252
]
5353
UNEXPECTED = "Unexpected!"
54+
EMPTY_VALUE = "NONE"
5455

5556
# Initialize the helper
5657
helper = CfnResource(json_logging=True, log_level=log_level, boto_level="CRITICAL", sleep_on_delete=120)
@@ -85,6 +86,8 @@ def create_ssm_parameter(ssm_client: SSMClient, name: str, value: str, parameter
8586
value: SSM parameter value
8687
parameter_type: SSM parameter type
8788
"""
89+
if not value:
90+
value = EMPTY_VALUE
8891
response = ssm_client.put_parameter(Name=name, Value=value, Type=parameter_type, Overwrite=True)
8992
LOGGER.debug({"API_Call": "ssm:PutParameter", "API_Response": response})
9093

aws_sra_examples/solutions/common/common_prerequisites/templates/sra-common-prerequisites-main-ssm.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Description:
88
repo, https://github.com/aws-samples/aws-security-reference-architecture-examples
99
Metadata:
1010
SRA:
11-
Version: 1.1
11+
Version: 1.2
1212
Entry: Parameters for deploying solution resolving SSM parameters
1313
Order: 1
1414
AWS::CloudFormation::Interface:
@@ -137,7 +137,10 @@ Parameters:
137137
ConstraintDescription:
138138
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
139139
Default: /sra/regions/enabled-regions
140-
Description: SSM Parameter for Enabled regions
140+
Description:
141+
SSM Parameter for Enabled regions. Regions that are enabled within all accounts in the AWS Organization. This list should include all enabled
142+
regions and not just the Control Tower governed regions. For example, it is recommended to enable GuardDuty in all active regions, which might
143+
include regions not governed by Control Tower.
141144
Type: AWS::SSM::Parameter::Value<List<String>>
142145
pEnabledRegionsWithoutHomeRegion:
143146
AllowedPattern: '^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$'
@@ -197,8 +200,8 @@ Parameters:
197200
Description: The SRA solution name. The Description value is the folder name of the solution
198201
Type: String
199202
pSRASolutionVersion:
200-
AllowedValues: [v1.1]
201-
Default: v1.1
203+
AllowedValues: [v1.2]
204+
Default: v1.2
202205
Description: The SRA solution version. Used to trigger updates on the nested StackSets.
203206
Type: String
204207
pSRAStagingS3BucketNamePrefix:
@@ -213,6 +216,7 @@ Conditions:
213216
cCreateSRAStagingS3BucketInMemberAccounts: !Equals [!Ref pCreateSRAStagingS3BucketInMemberAccounts, 'true']
214217
cCreateSSMParametersInMemberAccounts: !Equals [!Ref pCreateSSMParametersInMemberAccounts, 'true']
215218
cCreateAWSControlTowerExecutionRole: !Equals [!Ref pCreateAWSControlTowerExecutionRole, 'true']
219+
cMoreThanOneControlTowerGovernedRegion: !Not [!Equals [!Join [',', !Ref pCustomerControlTowerRegionsWithoutHomeRegion], 'NONE']]
216220

217221
Resources:
218222
rControlTowerExecutionRoleStack:
@@ -282,6 +286,7 @@ Resources:
282286
ParameterValue: !Ref pRootOrganizationalUnitId
283287

284288
rStagingS3BucketManagementAccountStackSet:
289+
Condition: cMoreThanOneControlTowerGovernedRegion
285290
Type: AWS::CloudFormation::StackSet
286291
Properties:
287292
StackSetName: sra-staging-s3-bucket-management-account-regions

aws_sra_examples/solutions/common/common_prerequisites/templates/sra-common-prerequisites-main.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Description:
88
https://github.com/aws-samples/aws-security-reference-architecture-examples
99
Metadata:
1010
SRA:
11-
Version: 1.1
11+
Version: 1.2
1212
Entry: Parameters for deploying solution without resolving SSM parameters
1313
Order: 1
1414
AWS::CloudFormation::Interface:
@@ -124,18 +124,23 @@ Parameters:
124124
Description: Customer Control Tower regions (2+ regions, separate by commas)
125125
Type: String
126126
pCustomerControlTowerRegionsWithoutHomeRegion:
127-
AllowedPattern: '^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
127+
AllowedPattern: '^$|^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
128128
ConstraintDescription:
129129
Only lowercase letters, numbers, and hyphens ('-') allowed. (e.g. us-east-1) Additional AWS regions can be provided, separated by commas without
130130
spaces. (e.g. us-east-1,ap-southeast-2)
131-
Description: Customer Control Tower regions without Home Region (2+ regions, separate by commas)
131+
Description:
132+
Customer Control Tower regions without Home Region (2+ regions, separate by commas). Leave blank when only one region is governed by Control
133+
Tower.
132134
Type: String
133135
pEnabledRegions:
134136
AllowedPattern: '^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
135137
ConstraintDescription:
136138
Only lowercase letters, numbers, and hyphens ('-') allowed. (e.g. us-east-1) Additional AWS regions can be provided, separated by commas without
137139
spaces. (e.g. us-east-1,ap-southeast-2)
138-
Description: Enabled regions (2+ regions, separate by commas)
140+
Description:
141+
Enabled regions (2+ regions, separate by commas). Regions that are enabled within all accounts in the AWS Organization. This list should include
142+
all enabled regions and not just the Control Tower governed regions. For example, it is recommended to enable GuardDuty in all active regions,
143+
which might include regions not governed by Control Tower.
139144
Type: String
140145
pEnabledRegionsWithoutHomeRegion:
141146
AllowedPattern: '^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
@@ -187,8 +192,8 @@ Parameters:
187192
Description: The SRA solution name. The Description value is the folder name of the solution
188193
Type: String
189194
pSRASolutionVersion:
190-
AllowedValues: [v1.1]
191-
Default: v1.1
195+
AllowedValues: [v1.2]
196+
Default: v1.2
192197
Description: The SRA solution version. Used to trigger updates on the nested StackSets.
193198
Type: String
194199
pSRAStagingS3BucketNamePrefix:
@@ -203,6 +208,7 @@ Conditions:
203208
cCreateSRAStagingS3BucketInMemberAccounts: !Equals [!Ref pCreateSRAStagingS3BucketInMemberAccounts, 'true']
204209
cCreateSSMParametersInMemberAccounts: !Equals [!Ref pCreateSSMParametersInMemberAccounts, 'true']
205210
cCreateAWSControlTowerExecutionRole: !Equals [!Ref pCreateAWSControlTowerExecutionRole, 'true']
211+
cMoreThanOneControlTowerGovernedRegion: !Not [!Equals [!Ref pCustomerControlTowerRegionsWithoutHomeRegion, '']]
206212

207213
Resources:
208214
rControlTowerExecutionRoleStack:
@@ -215,8 +221,6 @@ Resources:
215221
Tags:
216222
- Key: sra-solution
217223
Value: !Ref pSRASolutionName
218-
Parameters:
219-
pCreateAWSControlTowerExecutionRole: !Ref pCreateAWSControlTowerExecutionRole
220224

221225
rSSMParametersMemberAccountsStackSet:
222226
Condition: cCreateSSMParametersInMemberAccounts
@@ -257,7 +261,7 @@ Resources:
257261
- ParameterKey: pCustomerControlTowerRegions
258262
ParameterValue: !Ref pCustomerControlTowerRegions
259263
- ParameterKey: pCustomerControlTowerRegionsWithoutHomeRegion
260-
ParameterValue: !Ref pCustomerControlTowerRegionsWithoutHomeRegion
264+
ParameterValue: !If [cMoreThanOneControlTowerGovernedRegion, !Split [',', pCustomerControlTowerRegionsWithoutHomeRegion], 'NONE']
261265
- ParameterKey: pEnabledRegions
262266
ParameterValue: !Ref pEnabledRegions
263267
- ParameterKey: pEnabledRegionsWithoutHomeRegion
@@ -274,6 +278,7 @@ Resources:
274278
ParameterValue: !Ref pRootOrganizationalUnitId
275279

276280
rStagingS3BucketManagementAccountStackSet:
281+
Condition: cMoreThanOneControlTowerGovernedRegion
277282
Type: AWS::CloudFormation::StackSet
278283
Properties:
279284
StackSetName: sra-staging-s3-bucket-management-account-regions

aws_sra_examples/solutions/common/common_prerequisites/templates/sra-common-prerequisites-member-account-parameters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Description:
99
https://github.com/aws-samples/aws-security-reference-architecture-examples
1010
Metadata:
1111
SRA:
12-
Version: 1.0
12+
Version: 1.1
1313
Order: 5
1414
AWS::CloudFormation::Interface:
1515
ParameterGroups:
@@ -71,7 +71,7 @@ Parameters:
7171
Description: Customer Control Tower regions (2+ regions, separate by commas)
7272
Type: String
7373
pCustomerControlTowerRegionsWithoutHomeRegion:
74-
AllowedPattern: '^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
74+
AllowedPattern: '^([a-zA-Z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
7575
ConstraintDescription:
7676
Only lowercase letters, numbers, and hyphens ('-') allowed. (e.g. us-east-1) Additional AWS regions can be provided, separated by commas. (e.g.
7777
us-east-1,ap-southeast-2)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tool.poetry]
22
name = "aws_sra_examples"
3-
version = "2.0.0"
3+
version = "2.0.1"
44
description = "AWS Security Reference Architecture Examples"
55
authors = ["Amazon Web Services <no_reply@amazon.com>"]
66

77
[tool.poetry.dependencies]
88
python = "^3.9"
99
boto3 = "^1.18.42"
10-
crhelper = "^2.0.10"
10+
crhelper = "^2.0.1"
1111

1212
[tool.poetry.dev-dependencies]
1313
pytest = "^6.2.5"

0 commit comments

Comments
 (0)