Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion src/control-tower/control-tower-landing-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export interface ControlTowerLandingZoneProps {
* @default - AWS best practices organizational structure
*/
readonly organizationStructure?: { [key: string]: OrganizationalUnit };
/**
* Whether to create the Control Tower admin role if it doesn't already exist.
* If false, the construct will attempt to reference an existing role with the name 'AWSControlTowerAdmin'.
* @default - true
*/
readonly createControlTowerAdminRole?: boolean;
}

/**
Expand Down Expand Up @@ -127,6 +133,8 @@ export class ControlTowerLandingZone extends Construct {
public readonly logArchiveAccountId?: string;
/** The AWS account ID of the security audit account */
public readonly securityAuditAccountId?: string;
/** The Control Tower admin role (either created or referenced) */
public readonly controlTowerAdminRole: iam.IRole;

/**
* Creates a new Control Tower Landing Zone.
Expand Down Expand Up @@ -225,6 +233,15 @@ export class ControlTowerLandingZone extends Construct {
},
};

const controlTowerAdminRole = props.createControlTowerAdminRole !== false
? new iam.Role(this, 'ControlTowerAdminRole', {
roleName: 'AWSControlTowerAdmin',
assumedBy: new iam.ServicePrincipal('controltower.amazonaws.com'),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AWSControlTowerAdmin'),
],
})
: iam.Role.fromRoleName(this, 'ControlTowerAdminRole', 'AWSControlTowerAdmin');

const baseManifest = {
governedRegions: props.governedRegions ?? [Stack.of(this).region],
Expand All @@ -251,7 +268,7 @@ export class ControlTowerLandingZone extends Construct {
version: '3.3',
});

// Hacky but I want to be sure the KMS key and grant exists before moving forward.
// Hacky but I want to be sure the KMS key and grant exists before moving forward.
if (logArchiveAccount) {
landingZone.node.addDependency(logArchiveAccount);
if (loggingKmsKey) {
Expand All @@ -268,6 +285,7 @@ export class ControlTowerLandingZone extends Construct {
landingZone.node.addDependency(loggingKmsKey);
}

this.controlTowerAdminRole = controlTowerAdminRole;
this.landingZoneArn = landingZone.attrArn;
this.landingZoneId = landingZone.attrLandingZoneIdentifier;
this.loggingKmsKeyArn = props.loggingBucketKmsKeyArn ?? loggingKmsKey?.keyArn;
Expand Down
Loading