-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMDCT-4226 - sets up deploy-prerequisites to create resources needed …
…in AWS account (#15025) Co-authored-by: Jon Holman <[email protected]>
- Loading branch information
1 parent
20821ba
commit f634b78
Showing
7 changed files
with
133 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env node | ||
import "source-map-support/register"; | ||
import { | ||
aws_apigateway as apigateway, | ||
aws_iam as iam, | ||
App, | ||
DefaultStackSynthesizer, | ||
Stack, | ||
StackProps, | ||
Tags, | ||
} from "aws-cdk-lib"; | ||
import { CloudWatchLogsResourcePolicy } from "./constructs/cloudwatch-logs-resource-policy"; | ||
import { loadDefaultSecret } from "./deployment-config"; | ||
import { getSecret } from "./utils/secrets-manager"; | ||
import { Construct } from "constructs"; | ||
|
||
interface PrerequisiteConfigProps { | ||
project: string; | ||
iamPath: string; | ||
iamPermissionsBoundaryArn: string; | ||
} | ||
|
||
export class PrerequisiteStack extends Stack { | ||
constructor( | ||
scope: Construct, | ||
id: string, | ||
props: StackProps & PrerequisiteConfigProps | ||
) { | ||
super(scope, id, props); | ||
|
||
const { | ||
project, | ||
iamPermissionsBoundaryArn, | ||
iamPath, | ||
} = props; | ||
|
||
new CloudWatchLogsResourcePolicy(this, "logPolicy", { project }); | ||
|
||
const cloudWatchRole = new iam.Role( | ||
this, | ||
"ApiGatewayRestApiCloudWatchRole", | ||
{ | ||
assumedBy: new iam.ServicePrincipal("apigateway.amazonaws.com"), | ||
permissionsBoundary: iam.ManagedPolicy.fromManagedPolicyArn( | ||
this, | ||
"iamPermissionsBoundary", | ||
iamPermissionsBoundaryArn | ||
), | ||
path: iamPath, | ||
managedPolicies: [ | ||
iam.ManagedPolicy.fromAwsManagedPolicyName( | ||
"service-role/AmazonAPIGatewayPushToCloudWatchLogs" | ||
), | ||
], | ||
} | ||
); | ||
|
||
new apigateway.CfnAccount( | ||
this, | ||
"ApiGatewayRestApiAccount", | ||
{ | ||
cloudWatchRoleArn: cloudWatchRole.roleArn, | ||
} | ||
); | ||
} | ||
} | ||
|
||
async function main() { | ||
const app = new App({ | ||
defaultStackSynthesizer: new DefaultStackSynthesizer( | ||
JSON.parse((await getSecret("cdkSynthesizerConfig"))!) | ||
), | ||
}); | ||
|
||
Tags.of(app).add("PROJECT", "SEDS"); | ||
|
||
const project = process.env.PROJECT!; | ||
new PrerequisiteStack(app, "seds-prerequisites", { | ||
project, | ||
...(await loadDefaultSecret(project)), | ||
env: { | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
region: process.env.CDK_DEFAULT_REGION, | ||
}, | ||
}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters