Skip to content

Commit 985e404

Browse files
committed
adding cdk-extension example
1 parent c3592f5 commit 985e404

File tree

6 files changed

+150
-0
lines changed

6 files changed

+150
-0
lines changed

aws-node-cdk-extension/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Welcome to your CDK JavaScript project
2+
3+
This is a blank project for CDK development with JavaScript.
4+
5+
The `cdk.json` file tells the CDK Toolkit how to execute your app. The build step is not required when using JavaScript.
6+
7+
## Useful commands
8+
9+
* `serverless ext cdk deploy` deploy this stack to your default AWS account/region
10+
* `serverless ext cdk diff` compare deployed stack with current state
11+
* `serverless ext cdk synth` emits the synthesized CloudFormation template

aws-node-cdk-extension/bin/example.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
3+
const cdk = require('aws-cdk-lib');
4+
const { ExampleStack } = require('../lib/example-stack');
5+
6+
const app = new cdk.App();
7+
new ExampleStack(app, 'ExampleStack', {
8+
/* If you don't specify 'env', this stack will be environment-agnostic.
9+
* Account/Region-dependent features and context lookups will not work,
10+
* but a single synthesized template can be deployed anywhere. */
11+
12+
/* Uncomment the next line to specialize this stack for the AWS Account
13+
* and Region that are implied by the current CLI configuration. */
14+
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
15+
16+
/* Uncomment the next line if you know exactly what Account and Region you
17+
* want to deploy the stack to. */
18+
// env: { account: '123456789012', region: 'us-east-1' },
19+
20+
/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */
21+
});

aws-node-cdk-extension/cdk.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"app": "node bin/example.js",
3+
"progress": "events",
4+
"watch": {
5+
"include": [
6+
"**"
7+
],
8+
"exclude": [
9+
"README.md",
10+
"cdk*.json",
11+
"jest.config.js",
12+
"package*.json",
13+
"yarn.lock",
14+
"node_modules",
15+
"test"
16+
]
17+
},
18+
"context": {
19+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
20+
"@aws-cdk/core:checkSecretUsage": true,
21+
"@aws-cdk/core:target-partitions": [
22+
"aws",
23+
"aws-cn"
24+
],
25+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
26+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
27+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
28+
"@aws-cdk/aws-iam:minimizePolicies": true,
29+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
30+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
31+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
32+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
33+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
34+
"@aws-cdk/core:enablePartitionLiterals": true,
35+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
36+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
37+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
38+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
39+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
40+
"@aws-cdk/aws-route53-patters:useCertificate": true,
41+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
42+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
43+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
44+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
45+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
46+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
47+
"@aws-cdk/aws-redshift:columnId": true,
48+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
49+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
50+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
51+
"@aws-cdk/aws-kms:aliasNameRef": true,
52+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
53+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
54+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
55+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
56+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
57+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
58+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
59+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
60+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
61+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { Stack, Duration, CfnOutput } = require('aws-cdk-lib')
2+
const sqs = require('aws-cdk-lib/aws-sqs')
3+
4+
class ExampleStack extends Stack {
5+
/**
6+
*
7+
* @param {Construct} scope
8+
* @param {string} id
9+
* @param {StackProps=} props
10+
*/
11+
constructor (scope, id, props) {
12+
super(scope, id, props)
13+
14+
// The code that defines your stack goes here
15+
16+
// example resource
17+
const queue = new sqs.Queue(this, 'ExampleQueue', {
18+
visibilityTimeout: Duration.seconds(300)
19+
})
20+
21+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22+
const queueUrlOutput = new CfnOutput(this, 'queueUrl', {
23+
value: queue.queueUrl
24+
})
25+
26+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
27+
const customOutput = new CfnOutput(this, 'customOutput', {
28+
value: 'customOutputValue',
29+
description: 'This is a custom output'
30+
})
31+
}
32+
}
33+
34+
module.exports = { ExampleStack }

aws-node-cdk-extension/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "example",
3+
"version": "0.1.0",
4+
"bin": {
5+
"example": "bin/example.js"
6+
},
7+
"devDependencies": {
8+
"aws-cdk": "2.131.0",
9+
"jest": "^29.7.0"
10+
},
11+
"dependencies": {
12+
"aws-cdk-lib": "2.131.0",
13+
"constructs": "^10.0.0"
14+
}
15+
}

aws-node-cdk-extension/serverless.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
service: aws-node-cdk-extension
2+
3+
cdk-instance:
4+
extension: serverless/cdk@latest
5+
config:
6+
region: us-east-2

0 commit comments

Comments
 (0)