Skip to content
Draft
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
4 changes: 3 additions & 1 deletion packages/cdk-appconfig-examples/bin/cdk-examples.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { HostedConfigurationStack, LambdaExtensionStack } from '../lib';
import { HostedConfigurationStack, LambdaExtensionStack, CodePipelineStack } from '../lib';

const app = new cdk.App();

new HostedConfigurationStack(app, 'AppConfigExample-HostedConfiguration');

new LambdaExtensionStack(app, 'AppConfigExample-LambdaExtension');

new CodePipelineStack(app, 'AppConfigExample-CodePipeline');
124 changes: 124 additions & 0 deletions packages/cdk-appconfig-examples/lib/code-pipeline-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Reference: https://aws.amazon.com/blogs/mt/automating-feature-release-using-aws-appconfig-integration-with-aws-codepipeline/
*/

import * as cdk from '@aws-cdk/core';
import * as codecommit from '@aws-cdk/aws-codecommit';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as actions from '@aws-cdk/aws-codepipeline-actions';

import * as appconfig from '@cuperman/cdk-appconfig';
import * as moreActions from '@cuperman/cdk-codepipeline-actions';

export class CodePipelineStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const pipelineName = 'ListServicesCodePipelineConfigProfile';

const app = new appconfig.Application(this, 'App', {
name: 'ListServices',
description: 'Configuration management for List-services application'
});

const devEnv = new appconfig.Environment(this, 'DevEnv', {
application: app,
name: 'development'
});

const testEnv = new appconfig.Environment(this, 'TestEnv', {
application: app,
name: 'testing'
});

const prodEnv = new appconfig.Environment(this, 'ProdEnv', {
application: app,
name: 'production'
});

const profile = new appconfig.CodePipelineConfigurationProfile(this, 'Profile', {
application: app,
name: pipelineName,
pipelineName,
validators: [
appconfig.JsonSchemaValidator.fromInline(`
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "AppConfig Validator example",
"type": "object",
"properties": {
"boolEnableLimitResults": {
"type": "boolean"
},
"intResultLimit": {
"type": "number"
}
},
"minProperties": 2,
"required": [
"intResultLimit",
"boolEnableLimitResults"
]
}
`)
]
});

const strategy = appconfig.DeploymentStrategy.fromDeploymentStrategyId(this, 'Strategy', 'AppConfig.AllAtOnce');

const pipeline = new codepipeline.Pipeline(this, 'Pipeline', {
pipelineName
});

const sourceOutput = new codepipeline.Artifact();

const repo = new codecommit.Repository(this, 'Repo', {
repositoryName: 'ListServices'
});

pipeline.addStage({
stageName: 'Source',
actions: [
new actions.CodeCommitSourceAction({
actionName: 'Source',
repository: repo,
branch: 'main',
output: sourceOutput
})
]
});

pipeline.addStage({
stageName: 'Deploy',
actions: [
new moreActions.AppConfigDeployAction({
runOrder: 1,
actionName: 'Deploy-development',
input: sourceOutput,
environment: devEnv,
configurationProfile: profile,
deploymentStrategy: strategy,
configurationPath: 'config/configdoc.json'
}),
new moreActions.AppConfigDeployAction({
runOrder: 2,
actionName: 'Deploy-testing',
input: sourceOutput,
environment: testEnv,
configurationProfile: profile,
deploymentStrategy: strategy,
configurationPath: 'config/configdoc.json'
}),
new moreActions.AppConfigDeployAction({
runOrder: 3,
actionName: 'Deploy-production',
input: sourceOutput,
environment: prodEnv,
configurationProfile: profile,
deploymentStrategy: strategy,
configurationPath: 'config/configdoc.json'
})
]
});
}
}
1 change: 1 addition & 0 deletions packages/cdk-appconfig-examples/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './code-pipeline-stack';
export * from './hosted-configuration-stack';
export * from './lambda-extension-stack';
12 changes: 8 additions & 4 deletions packages/cdk-appconfig-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@
"prepublishOnly": "run-s test"
},
"devDependencies": {
"@aws-cdk/assert": "1.110.1",
"@aws-cdk/assert": "1.112.0",
"@types/jest": "^26.0.10",
"@types/node": "10.17.27",
"aws-cdk": "1.110.1",
"aws-cdk": "1.112.0",
"jest": "^26.4.2",
"npm-run-all": "^4.1.5",
"ts-jest": "^26.2.0",
"ts-node": "^9.0.0",
"typescript": "~3.9.7"
},
"dependencies": {
"@aws-cdk/aws-lambda": "^1.110.1",
"@aws-cdk/core": "1.110.1",
"@aws-cdk/aws-codecommit": "^1.112.0",
"@aws-cdk/aws-codepipeline": "1.112.0",
"@aws-cdk/aws-codepipeline-actions": "1.112.0",
"@aws-cdk/aws-lambda": "1.112.0",
"@aws-cdk/core": "1.112.0",
"@cuperman/cdk-appconfig": "^0.7.0",
"@cuperman/cdk-appconfig-handler-hello-world": "^0.7.0",
"@cuperman/cdk-codepipeline-actions": "^0.7.0",
"source-map-support": "^0.5.16"
}
}
Loading