Last active
January 23, 2021 06:17
-
-
Save sasaken555/868ecccbda26a7b950202a10bbc54c3e to your computer and use it in GitHub Desktop.
AWS CDK stack to create repository and application.
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
import * as cdk from '@aws-cdk/core'; | |
import * as codecommit from '@aws-cdk/aws-codecommit'; | |
import * as amplify from '@aws-cdk/aws-amplify'; | |
// https://aws.amazon.com/jp/blogs/mobile/deploying-a-static-website-with-aws-amplify-and-cdk/ | |
export class AmplifyAppStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
// create repository | |
const appName = 'nextjs-blog-app'; | |
const nextjsBlogAppRepo = new codecommit.Repository( | |
this, | |
'NextjsBlogAppRepo', | |
{ | |
repositoryName: appName, | |
description: 'CodeCommit Repository that will be used to store front-end app with CDK', | |
}, | |
); | |
// create Amplify application | |
const amplifyApp = new amplify.App(this, appName, { | |
sourceCodeProvider: new amplify.CodeCommitSourceCodeProvider({ | |
repository: nextjsBlogAppRepo, | |
}), | |
}); | |
// connect Amplify with branch to publish | |
const branchName = 'master'; | |
amplifyApp.addBranch(branchName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment