Skip to content

Commit 8f41ba6

Browse files
committed
Merge branch 'main' into configRole
2 parents a01e870 + c7564c7 commit 8f41ba6

File tree

11 files changed

+140
-96
lines changed

11 files changed

+140
-96
lines changed

aws_sra_examples/docs/CFCT-DEPLOYMENT-INSTRUCTIONS.md

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-
44

55
---
66

7+
CfCT is a deployment mechanism for SRA solutions within Control Tower enabled AWS environments.
8+
The requisite [SRA solution configuration files](https://github.com/aws-samples/aws-security-reference-architecture-examples/tree/main/aws_sra_examples/solutions) are stored in either CodeCommit (deprecated service) or S3 and programmatically configured in AWS with a CodePipeline. Whether you're using the sra-easy-setup deployment method or deploying SRA controls ADHOC, the CfCT deployment mechanism makes managing and customizing SRA solutions easier.
9+
10+
711
## Table of Contents<!-- omit in toc -->
812

913
- [Prerequisites](#prerequisites)
14+
- [Deploy Control Tower](#deploy-control-tower)
1015
- [Create the AWSControlTowerExecution IAM Role](#create-the-awscontroltowerexecution-iam-role)
1116
- [Deploy Customizations for AWS Control Tower (CFCT) Solution](#deploy-customizations-for-aws-control-tower-cfct-solution)
1217
- [AWS CodeCommit Repo](#aws-codecommit-repo)
18+
- [AWS S3 Repo](#aws-s3-repo)
19+
- [Configure SRA Deployment Repo](#configue-your-sra-deployment-repo)
1320
- [References](#references)
1421

22+
1523
## Prerequisites
1624

25+
### Deploy Control Tower
26+
27+
- These customizations act on existing Control Tower deployments. For more details on Control Tower and Landing Zone deployments, see the [userguide](https://docs.aws.amazon.com/controltower/latest/userguide/quick-start.html).
28+
1729
### Create the AWSControlTowerExecution IAM Role
1830

1931
- The `AWSControlTowerExecution` Role provides the support needed to deploy solutions to the `management account` across regions as CloudFormation `StackSets` and it is required for the SRA CFCT solution deployments.
@@ -27,18 +39,31 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-
2739
<!-- markdownlint-disable-next-line MD034 -->
2840
- `Amazon S3 URL` = https://s3.amazonaws.com/solutions-reference/customizations-for-aws-control-tower/latest/custom-control-tower-initiation.template
2941
- `Stack name` = custom-control-tower-initiation
30-
- `AWS CodePipeline Source` = AWS CodeCommit
42+
- `AWS CodePipeline Source` = AWS CodeCommit | S3
3143
- `Failure Tolerance Percentage` = 0
3244
- Acknowledge that AWS CloudFormation might create IAM resources with custom names
3345

3446
Note: Version 2 or higher of CfCT is expected.
3547

3648
### AWS CodeCommit Repo
49+
*Note: AWS CodeCommit is being deprecated and cannot be deployed to new environments, unless that environment is a part of an AWS Organization with an account that already has CodeCommit deployed. Please see [AWS S3 Repo](#aws-s3-repo) for new AWS Accounts.*
50+
51+
Create a CodeCommit repo for SRA customization [configuration files](#deployment-instructions).
3752

3853
1. On the local machine install [git](https://git-scm.com/downloads) and [git-remote-codecommit](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-connect.html).
3954
2. Clone the AWS CodeCommit repository via `git clone codecommit::<HOME REGION>://custom-control-tower-configuration custom-control-tower-configuration`
4055

56+
### AWS S3 Repo
57+
58+
Create a CodeCommit repo for SRA cusotmization [configuration files](#deployment-instructions).
59+
60+
- By default, the CodePipeline deployed from the custom-control-tower-initiation CloudFormation will use the `custom-control-tower-configuration-<< ACCOUNT NAME >>-<< REGION NAME >>` S3 bucket as a Source repo. Additionally, it will look for the `custom-control-tower-configuration.zip` file. The pipeline will fail without it. We have provided users with an example `_custom-control-tower-configuration.zip` file in S3 with an example repo for convenience.
61+
62+
- If you would like to change the S3 bucket Source for the CodePipeline, you will need to navigate to the CodePipeline within the AWS console, edit the Source stage for the CodePipeline and update the Bucket name value. Users can also modify the S3 object key value if the ZIP filename differs from default.
63+
64+
4165
## Deployment Instructions<!-- omit in toc -->
66+
*Note: these instructions assume version 2 or higher of the CfCT solution has been installed.*
4267

4368
1. Determine which version of the [Customizations for AWS Control Tower](https://aws.amazon.com/solutions/implementations/customizations-for-aws-control-tower/) solution you have deployed:
4469
1. Within the `management account (home region)` find the **CloudFormation Stack** for the Customizations for Control Tower (e.g. `custom-control-tower-initiation`)
@@ -48,18 +73,59 @@ Note: Version 2 or higher of CfCT is expected.
4873
2. Version 2 = v2.x.x = manifest.yaml version 2021-03-15
4974
2. If version 2 is installed, continue to the deployment instructions below. If not, you will need to update your version of CfCT.
5075

51-
#### Deployment Instructions<!-- omit in toc -->
5276

53-
Note: these instructions assume version 2 or higher of the CfCT solution has been installed.
77+
##### Configue Your SRA Deployment Repo
78+
79+
SRA Customizations with CfCT are deployed via a CodePipeline from either a CodeCommit or S3 source.
80+
Here's an example of an repo for sra-easy-deploy.yaml deployment with controls/parameters for GuardDuty.
81+
82+
> ├── manifest.yaml
83+
> |
84+
> ├── templates
85+
> │   └── sra-easy-setup.yaml
86+
> |
87+
> ├── parameters
88+
> │   └── sra-guardduty-org-main-ssm.json
89+
> |
90+
> ├── policies
91+
92+
93+
###### manifest.yaml file [**required**]
94+
95+
The manifest file will contain all the high level SRA controls that will be deployed to your environment.
96+
An example manifest file for [sra-easy-setup.yaml](https://github.com/aws-samples/aws-security-reference-architecture-examples/blob/main/aws_sra_examples/easy_setup/customizations_for_aws_control_tower/manifest.yaml)
97+
98+
- Define all `parameters`, `organizational unit names`, `account names` and `SSM parameters` necessary for the SRA controls that you want to enable and configure here.
99+
100+
- If you are using a non-standard file structure in your Repo, as outlined above, the [*resource_file* key](https://github.com/aws-samples/aws-security-reference-architecture-examples/blob/main/aws_sra_examples/easy_setup/customizations_for_aws_control_tower/manifest.yaml#L13C5-L13C49) value in your manifest file must reflect the path to your template.
101+
102+
- Be sure to update the [*accounts* key](https://github.com/aws-samples/aws-security-reference-architecture-examples/blob/main/aws_sra_examples/easy_setup/customizations_for_aws_control_tower/manifest.yaml#L310) to reflect your Management Account name.
103+
104+
###### templates [**required**]
105+
106+
The templates directory will contain the actual CloudFormation files that are defined within the manifest file.
107+
We use the sra-easy-setup deployment method as an example for the manifest above, [here's](https://github.com/aws-samples/aws-security-reference-architecture-examples/blob/main/aws_sra_examples/easy_setup/templates/sra-easy-setup.yaml) what the template file looks like.
108+
109+
You can also deploy SRA solutions ADHOC, without the sra-easy-setup, by including their corresponding manifest CFN template entry under the resources list for your manifest.yaml file. Exmaples of manifest files for supported solutions can be found within the `aws_sra_examples` repo [aws_sra_examples/solutions/<< SOLUTION NAME >>/customizations_for_aws_control_tower/manifest.yaml](https://github.com/aws-samples/aws-security-reference-architecture-examples/tree/main/aws_sra_examples/solutions).
110+
111+
- You shouldn't need to modify much in this template file as all SRA controls and parameters are defined in the manifest and files under the parameters directory, respectively.
112+
113+
###### policies [optional]
114+
115+
Service control policy JSON files go here. The files under the Policies directory will depend on what SRA controls that you're deploying to your environment. Not all SRA controls will require policies defined here.
116+
117+
###### parameters [optional]
118+
119+
Service control parameter JSON files go here. The files under the Parameters directory will depend on what SRA controls that you're deploying to your environment. Not all SRA controls will require parameters defined here.
120+
121+
Above, we used the [sra-guardduty-org-main-ssm.json](https://github.com/aws-samples/aws-security-reference-architecture-examples/blob/main/aws_sra_examples/solutions/guardduty/guardduty_org/customizations_for_aws_control_tower/parameters/sra-guardduty-org-main-ssm.json) parameters file as an example for our sra-easy-setup deploying GuardDuty controls in AWS.
122+
123+
You can find examples of parameter files for each security solution that we support within the `aws_sra_examples` repo [aws_sra_examples/solutions/<< SOLUTION NAME >>/customizations_for_aws_control_tower/parameters/](https://github.com/aws-samples/aws-security-reference-architecture-examples/tree/main/aws_sra_examples/solutions).
124+
125+
126+
##### Push To CodeCommit or S3
127+
*Note: If you are using S3, the files above will need to be ZIPPED up and named `custom-control-tower-configuration`.*
54128

55-
1. Copy the files to the Customizations for AWS Control Tower configuration `custom-control-tower-configuration`
56-
- policies [optional]
57-
- service control policies files (\*.json)
58-
- templates [**required**]
59-
- Copy the template files from the `templates` folder that are referenced in the `manifest.yaml`
60-
2. Update the manifest.yaml file with the `parameters`, `organizational unit names`, `account names` and `SSM parameters` for the target environment
61-
- *Be sure to update `deployment_targets` `accounts` with your management account information*
62-
3. Deploy the Customizations for AWS Control Tower configuration by pushing the code to the `AWS CodeCommit` repository or uploading to the `AWS S3 Bucket`
63129

64130
### Delete Instructions<!-- omit in toc -->
65131

@@ -72,6 +138,7 @@ Note: these instructions assume version 2 or higher of the CfCT solution has bee
72138
1. Delete the Stack Instances from the `CustomControlTower-<solution_name>*` CloudFormation StackSets
73139
2. After the Stack Instances are deleted, delete the `CustomControlTower-<solution_name>*` CloudFormation StackSets
74140

141+
75142
## References
76143

77-
- [Customizations for AWS Control Tower](https://aws.amazon.com/solutions/implementations/customizations-for-aws-control-tower/)
144+
- [Customizations for AWS Control Tower](https://aws.amazon.com/solutions/implementations/customizations-for-aws-control-tower/)

aws_sra_examples/modules/guardduty-org-module/templates/sra-guardduty-org-module-main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,9 @@ Outputs:
12031203
oPublishingDestinationBucketArn:
12041204
Description: Publishing Destination Bucket Name
12051205
Value: !GetAtt [rGuardDutySolutionStack, Outputs.oPublishingDestinationBucketArn]
1206-
oGuardDutyDeliveryKeyArn:
1207-
Description: GuardDuty Delivery KMS Key ARN
1208-
Value: !GetAtt [rGuardDutySolutionStack, Outputs.oGuardDutyDeliveryKeyArn]
1206+
# oGuardDutyDeliveryKeyArn:
1207+
# Description: GuardDuty Delivery KMS Key ARN
1208+
# Value: !GetAtt [rGuardDutySolutionStack, Outputs.oGuardDutyDeliveryKeyArn]
12091209
oAuditAccountId:
12101210
Description: Audit Account ID
12111211
Value: !GetAtt rGetCommonOutputsCustomResource.oAuditAccountId

aws_sra_examples/modules/guardduty-org-module/templates/sra-guardduty-org-solution.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ Outputs:
967967
Condition: cDeployGuardDutySolution
968968
Description: Publishing Destination Bucket Name
969969
Value: !GetAtt [rGuardDutySolutionStack, Outputs.oPublishingDestinationBucketArn]
970-
oGuardDutyDeliveryKeyArn:
971-
Condition: cDeployGuardDutySolution
972-
Description: GuardDuty Delivery KMS Key ARN
973-
Value: !GetAtt [rGuardDutySolutionStack, Outputs.oGuardDutyDeliveryKeyArn]
970+
# oGuardDutyDeliveryKeyArn:
971+
# Condition: cDeployGuardDutySolution
972+
# Description: GuardDuty Delivery KMS Key ARN
973+
# Value: !GetAtt [rGuardDutySolutionStack, Outputs.oGuardDutyDeliveryKeyArn]

aws_sra_examples/solutions/ami_bakery/ami_bakery_org/lambda/src/codepipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def create_codepipeline(
9090
"roleArn": "arn:" + aws_partition + ":iam::" + account_id + ":role/" + codepipeline_role_name,
9191
"artifactStore": {"type": "S3", "location": bucket_name},
9292
"stages": [
93-
{
93+
{ # type: ignore
9494
"name": pipeline_name + "-CodeCommitSource",
9595
"actions": [
9696
{
@@ -104,7 +104,7 @@ def create_codepipeline(
104104
}
105105
],
106106
},
107-
{
107+
{ # type: ignore
108108
"name": pipeline_name + "-DeployEC2ImageBuilder",
109109
"actions": [
110110
{

aws_sra_examples/solutions/config/config_org/lambda/src/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def set_config_in_org(
9292
configuration_recorder: ConfigurationRecorderTypeDef = {
9393
"name": recorder_name,
9494
"roleARN": role_arn,
95-
"recordingGroup": {
95+
"recordingGroup": { # type: ignore
9696
"allSupported": all_supported,
9797
"includeGlobalResourceTypes": include_global_resource_types,
9898
"resourceTypes": resource_types,

aws_sra_examples/solutions/guardduty/guardduty_org/templates/sra-guardduty-org-configuration.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,19 @@ Parameters:
219219
Default: sra-guardduty-org-lambda
220220
Description: GuardDuty configuration Lambda role name
221221
Type: String
222+
# Turn this into a parameter as a default value instead.
222223
pKMSKeyArn:
223224
AllowedPattern: '^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+:\d{12}:key\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
224225
ConstraintDescription: 'Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'
225226
Description: Logging S3 bucket KMS Key ARN
226227
Type: String
228+
# pKMSKeyArn:
229+
# AllowedPattern: ^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$
230+
# ConstraintDescription:
231+
# Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
232+
# Default: /sra/guardduty_org_delivery_key_arn
233+
# Description: SSM Parameter for Guard Duty delivery key ARN.
234+
# Type: AWS::SSM::Parameter::Value<String>
227235
pLambdaLogGroupKmsKey:
228236
AllowedPattern: '^$|^arn:(aws[a-zA-Z-]*){1}:kms:[a-z0-9-]+:\d{12}:key\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
229237
ConstraintDescription: 'Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'
@@ -551,6 +559,7 @@ Resources:
551559
DISABLE_GUARD_DUTY: !Ref pDisableGuardDuty
552560
ENABLED_REGIONS: !Ref pEnabledRegions
553561
FINDING_PUBLISHING_FREQUENCY: !Ref pFindingPublishingFrequency
562+
# KMS_KEY_ARN: !Sub '{{resolve:ssm:arn:${AWS::Partition}:ssm:${AWS::Region}:${pDelegatedAdminAccountId}:parameter/sra/guardduty_org_delivery_key_arn}}'
554563
KMS_KEY_ARN: !Ref pKMSKeyArn
555564
PUBLISHING_DESTINATION_BUCKET_ARN: !Sub arn:${AWS::Partition}:s3:::${pPublishingDestinationBucketName}
556565
SNS_TOPIC_ARN: !Ref rGuardDutyOrgTopic

aws_sra_examples/solutions/guardduty/guardduty_org/templates/sra-guardduty-org-delivery-kms-key.yaml

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Metadata:
1717
default: General Properties
1818
Parameters:
1919
- pSRASolutionName
20-
- pSRASecretsKeyAliasArn
2120

2221
- Label:
2322
default: KMS Key Properties
@@ -33,8 +32,6 @@ Metadata:
3332
default: Organization Management Account ID
3433
pLogArchiveAccountId:
3534
default: Log Archive Account ID
36-
pSRASecretsKeyAliasArn:
37-
default: (Optional) SRA Secrets Manager KMS Key Alias ARN
3835
pSRASolutionName:
3936
default: SRA Solution Name
4037

@@ -54,20 +51,12 @@ Parameters:
5451
ConstraintDescription: Must be 12 digits
5552
Description: Management Account ID
5653
Type: String
57-
pSRASecretsKeyAliasArn:
58-
AllowedPattern: '^$|^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+:\d{12}:alias\/[a-zA-Z0-9/_-]+$'
59-
ConstraintDescription: 'Key Alias ARN example: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias'
60-
Description: (Optional) SRA Secrets Manager KMS Key Alias ARN
61-
Type: String
6254
pSRASolutionName:
6355
AllowedValues: [sra-guardduty-org]
6456
Default: sra-guardduty-org
6557
Description: The SRA solution name. The default value is the folder name of the solution
6658
Type: String
6759

68-
Conditions:
69-
cCreateSecret: !Not [!Equals [!Ref pSRASecretsKeyAliasArn, '']]
70-
7160
Resources:
7261
rGuardDutyDeliveryKey:
7362
Type: AWS::KMS::Key
@@ -138,50 +127,18 @@ Resources:
138127
- Key: sra-solution
139128
Value: !Ref pSRASolutionName
140129

141-
rGuardDutyDeliveryKeyAlias:
142-
Type: AWS::KMS::Alias
143-
Properties:
144-
AliasName: !Sub alias/${pGuardDutyOrgDeliveryKeyAlias}
145-
TargetKeyId: !Ref rGuardDutyDeliveryKey
146-
147-
rGuardDutyDeliveryKeySecret:
148-
Type: AWS::SecretsManager::Secret
149-
Condition: cCreateSecret
150-
Metadata:
151-
checkov:
152-
skip:
153-
- id: CKV_AWS_149
154-
comment: A cross-account KMS Key is used
130+
rGuardDutyDeliveryKeyParameter:
131+
Type: AWS::SSM::Parameter
132+
DeletionPolicy: Retain
155133
Properties:
156-
Name: sra/guardduty_org_delivery_key_arn
134+
Name: /sra/guardduty_org_delivery_key_arn
135+
Type: String
136+
Value: !Sub '{"GuardDutyDeliveryKeyArn":"${rGuardDutyDeliveryKey.Arn}"}'
157137
Description: GuardDuty Delivery KMS Key ARN
158-
SecretString: !Sub '{"GuardDutyDeliveryKeyArn":"${rGuardDutyDeliveryKey.Arn}"}' # checkov:skip=CKV_SECRET_6
159-
KmsKeyId: !Ref pSRASecretsKeyAliasArn
160138
Tags:
161-
- Key: sra-solution
162-
Value: !Ref pSRASolutionName
139+
sra-solution: !Ref pSRASolutionName
163140

164-
rGuardDutyDeliveryKeySecretPolicy:
165-
Type: AWS::SecretsManager::ResourcePolicy
166-
Condition: cCreateSecret
167-
Properties:
168-
BlockPublicPolicy: True
169-
SecretId: !Ref rGuardDutyDeliveryKeySecret
170-
ResourcePolicy:
171-
Version: 2012-10-17
172-
Statement:
173-
- Action: secretsmanager:GetSecretValue # checkov:skip=CKV_SECRET_6
174-
Effect: Allow
175-
Principal:
176-
AWS:
177-
- !Sub arn:${AWS::Partition}:iam::${pManagementAccountId}:root
178-
Resource: '*'
179-
Condition:
180-
ForAnyValue:StringEquals:
181-
secretsmanager:VersionStage: AWSCURRENT
182141
Outputs:
183142
oGuardDutyDeliveryKeyArn:
184143
Description: GuardDuty Delivery KMS Key ARN
185-
Value: !GetAtt rGuardDutyDeliveryKey.Arn
186-
# Export:
187-
# Name: eGuardDutyDeliveryKeyArn
144+
Value: !GetAtt rGuardDutyDeliveryKey.Arn

0 commit comments

Comments
 (0)