Cloudformation templates for AWS Integration with P0 Security
Summary: We will be using a cloudformation template to deploy a stackset in order to create an IAM Role and an Access Analyzer for P0 across all children accounts for an organization. Individual stacks will be deployed to a single region across all children accounts.
In order to cover the management account, we will then deploy a single stack via the same stackset to create the role and access analyzer in the management account.
Instructions: Please copy the current directory to your local instance and execute the following using the AWS Console.
- Sign in to the AWS Management Console
- Navigate to the CloudFormation service
- In the left navigation pane, click on StackSets
- Click the Create StackSet button
- Select Template is ready
- Choose Upload a template file
- Click Choose file and select the
assessment-template.yaml
- Click Next
- Enter a StackSet name (e.g., "P0SecurityRolesAndAnalyzers")
- Enter a Description (e.g., "Deploys P0 security roles across organization")
- Configure the parameters:
- GoogleFederationAudience: Leave as default (102346994864456724606)
- UnusedAccessAge: Leave as default (90) or adjust as needed
- CreateAccessAnalyzer: Leave as default ("Yes"), only set "No" to avoid the conflict with the existing analyzer
- Click Next
- Under Permissions, select Service-managed permissions
- Add any tags if desired (optional)
- For Execution configuration:
- Choose Active for deployments to run immediately
- Click Next
- Under Deployment targets, select Deploy to organization
- For Organizational Units - optional, you can leave it empty to deploy to all accounts or specify specific OUs
- For Automatic deployment, select Enabled to automatically deploy to new accounts
- Under Specify regions, select "us-east-1"
- For Deployment options:
- Maximum concurrent accounts: Choose a percentage (e.g., 25%) or number
- Failure tolerance: Choose a percentage (e.g., 25%) or number
- Region concurrency: Choose "Sequential" or "Parallel" based on preference
- Click Next
- Review all your settings and configuration
- Check the acknowledgment that confirms that IAM resources might be created
- Click Submit
- Modify the inline policy of the
CloudFormationStackSetAdministrationRole
and add the policy defined inCloudFormationStackSetAdministrationRole.json
to the existing inline policy. - Navigate to the CloudFormation service and to the Stacks section
- Create a new Stack using a new resource
- Use the same
assessment-template.yaml
to create a new Stack. - Choose
CloudFormationStackSetAdministrationRole
to deploy this Stack. - Click Submit
Summary: We will be using a cloudformation template to deploy a stackset in order to create an IAM Role for P0 across all children accounts for an organization. Individual stacks will be deployed to a single region across all the children accounts.
In order to cover the management account, we will then be deploying a stack manually via the same stackset to target the management account and create the same IAM Role for P0.
Instructions: Please copy the current directory to your local instance and execute the following using the AWS Console
- AWS -> Management Account -> Cloudformation -> StackSets
- Create StackSet
- Service-managed permissions
- Upload the
iam_management.json
template - Provide a StackSet name like
P0IAMRoleStackSet
- Enter Google Audience ID for P0
- Deploy New stacks
- Deploy to organization (This will ONLY deploy to children accounts)
- Pick a single active region aka
us-west-2
- Submit
- AWS -> Management Account -> Cloudformation -> Stack
- Create stack with new resources
- Choose an existing template
- Upload the
iam_management.json
template - Provide a Stack name like
P0IAMRoleStack
- Enter the Google Audience ID for P0
- Submit
- AWS -> Cloudformation -> StackSets
- Create a new stackset using the 'iam_resource_lister.yaml` template
- Use service-managed permissions
- Upload the
iam_resource_lister.yaml
template - Provide a StackSet name like
P0IAMRoleListerStackSet
- Enter Google Audience ID for P0
- Enter TargetAccountID as the parent Account ID (the value doesn't really matter, it'll be overridden)
- Deploy new stacks
- Deploy to organization
- Specify a single region (us-west-2), its not relevant as the IAM role will be global
- Submit
- AWS -> Cloudformation -> Stack
- Create a new stack using existing resources
- Choose an existing template
- Upload the
iam_resource_lister.yaml
template - Provide a Stack name like
P0IAMRoleListerStack
- Enter Google Audience ID for P0
- Enter TargetAccountID as the parent Account ID
- Submit
- AWS -> Cloudformation -> StackSets
- Create a new stackset
- Use service-managed permissions
- Upload the
resource_explorer_local_index.yaml
template - Provide a StackSet name like
LocalIndexStackSetForChildAccounts
- Deploy new stacks
- Deploy to organization
- Specify all active regions except one (which will be used for the aggregator index, we can use
us-west-2
as the exception) - Submit
- We'll be creating new IAM roles to use for self-managed permissions for the CF templates.
- AWS -> Cloudformation -> Stacks
- Create a new stack using existing resources
- Choose an existing template
- Upload the
stack_set_roles.yaml
template - Provide a Stack Name like
StackSetRoles
- Submit
- Now we'll create the local indexes in the management account
- AWS -> Cloudformation -> StackSets
- Create a new stack set
- Use self-service permissions
- Use IAM admin role created in step 3 -
AWSCloudFormationStackSetAdministrationRole
- Use IAM execution role created in step 3 -
AWSCloudFormationStackSetExecutionRole
- Upload same template from Step B.2 -
resource_explorer_local_index.yaml
- Provide a StackSet name like
LocalIndexStackSetForParentAccount
- Deploy stack sets in accounts: Put in the management account ID
- Specify all active regions except one (which will be used for the aggregator index, we can use
us-west-2
as the exception) - Submit
- AWS -> Cloudformation -> StackSets
- Create a new stackset
- Use service-managed permissions
- Upload the
resource_explorer_aggregator_index.yaml
template - Provide a StackSet name like
AggregatorIndexStackSetForChildAccounts
- Deploy new stacks
- Deploy to organization
- Specify the excluded active region from Step B.2.vi (e.g.
us-west-2
) - Submit
- We'll be using the same IAM roles as in Step C.3
- AWS -> Cloudformation -> StackSets
- Create a new stack set
- Use self-service permissions
- Use IAM admin role created in step C.3 -
AWSCloudFormationStackSetAdministrationRole
- Use IAM execution role created in step C.3 -
AWSCloudFormationStackSetExecutionRole
- Upload same template from Step D.2 -
resource_explorer_aggregator_index.yaml
- Provide a StackSet name like
AggregatorIndexStackSetForParentAccount
- Deploy stack sets in accounts: Put in the management account ID
- Specify the excluded active region from Step C.6.vii (e.g.
us-west-2
) - Submit
- AWS -> Cloudformation -> StackSets
- Create a new stackset
- Use service-managed permissions
- Upload the
resource_explorer_view.yaml
template - Provide a StackSet name like
ResourceExplorerViewStackSetForChildAccounts
- Set aggregator region to
us-west-2
- Deploy new stacks
- Deploy to organization
- Specify the same aggregator region as Step D.2.vi
- Submit
- AWS -> Cloudformation -> Stacks
- Create a new stack using existing resources
- Choose an existing template
- Upload the
resource_explorer_view.yaml
template - Provide a Stack name like
ResourceExplorerViewStack
- Specify the aggregator region as Step E.3.vii (
us-west-2
) - Enter TargetAccountID as the parent Account ID
- Submit