-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment-stack.ts
41 lines (36 loc) · 1.17 KB
/
deployment-stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Construct } from "constructs";
import { Stack, StackProps } from "aws-cdk-lib";
import { Role, ServicePrincipal, ManagedPolicy } from "aws-cdk-lib/aws-iam";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import {
App,
Branch,
GitHubSourceCodeProvider,
} from "@aws-cdk/aws-amplify-alpha";
export type DeploymentStackProps = StackProps & {
githubAccessToken: Secret;
};
/**
* Deploy a service-linked-role for Amplify to use to deploy CDK,
* then
*/
export class DeploymentStack extends Stack {
constructor(scope: Construct, id: string, props: DeploymentStackProps) {
super(scope, id, props);
const serviceRole = new Role(this, "AmplifyServiceRole", {
assumedBy: new ServicePrincipal("amplify.amazonaws.com"),
managedPolicies: [
ManagedPolicy.fromAwsManagedPolicyName("AdministratorAccess-Amplify"),
],
});
const app = new App(this, "AmplifyApp", {
sourceCodeProvider: new GitHubSourceCodeProvider({
owner: "dpilch",
repository: "sample-cdk-construct-app",
oauthToken: props.githubAccessToken.secretValue,
}),
role: serviceRole,
});
new Branch(this, "main", { app });
}
}