Skip to content

Commit 1cd1795

Browse files
authored
feat(samples/cloudwatch-applicationsignals-mcp): add ecs samples for enablement testing (#1727)
* add ecs samples for enablement testing * fix comments and pre-commit
1 parent 3855c16 commit 1cd1795

File tree

8 files changed

+230
-0
lines changed

8 files changed

+230
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
import * as cdk from 'aws-cdk-lib';
17+
import { ECSAppStack, AppConfig } from '../lib/cdk-stack';
18+
import * as fs from 'fs';
19+
import * as path from 'path';
20+
21+
const app = new cdk.App();
22+
23+
// Use account/region from environment or CLI config
24+
const env = {
25+
account: process.env.CDK_DEFAULT_ACCOUNT,
26+
region: process.env.CDK_DEFAULT_REGION,
27+
};
28+
29+
// Read all config files from config directory
30+
const configDir = fs.realpathSync(path.resolve(__dirname, '../config'));
31+
const configFiles = fs.readdirSync(configDir).filter(f => f.endsWith('.json'));
32+
33+
// Create a stack for each config
34+
configFiles.forEach(configFile => {
35+
const configPath = path.join(configDir, configFile);
36+
const config: AppConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
37+
38+
// Convert appName to PascalCase for stack ID (e.g., python-flask -> PythonFlask)
39+
const stackId = config.appName
40+
.split('-')
41+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
42+
.join('') + 'Stack';
43+
44+
new ECSAppStack(app, stackId, config, { env });
45+
});
46+
47+
app.synth();
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/cdk.ts",
3+
"context": {
4+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
5+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
6+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
7+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
8+
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
9+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
10+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
11+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
12+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
13+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
14+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
15+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
16+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
17+
"@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
18+
"@aws-cdk/aws-dynamodb:retainTableReplica": true,
19+
"@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true,
20+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
21+
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
22+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
23+
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
24+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
25+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
26+
"@aws-cdk/aws-ecs-patterns:secGroupsDisablesImplicitOpenListener": true,
27+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
28+
"@aws-cdk/aws-ecs:disableEcsImdsBlocking": true,
29+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
30+
"@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature": false,
31+
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
32+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
33+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
34+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
35+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
36+
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
37+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
38+
"@aws-cdk/aws-events:requireEventBusPolicySid": true,
39+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
40+
"@aws-cdk/aws-iam:minimizePolicies": true,
41+
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
42+
"@aws-cdk/aws-kms:aliasNameRef": true,
43+
"@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal": true,
44+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
45+
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
46+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
47+
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
48+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
49+
"@aws-cdk/aws-lambda:useCdkManagedLogGroup": true,
50+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
51+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
52+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
53+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
54+
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
55+
"@aws-cdk/aws-redshift:columnId": true,
56+
"@aws-cdk/aws-route53-patters:useCertificate": true,
57+
"@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true,
58+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
59+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
60+
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
61+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
62+
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
63+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
64+
"@aws-cdk/aws-signer:signingProfileNamePassedToCfn": true,
65+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
66+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
67+
"@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true,
68+
"@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
69+
"@aws-cdk/core:aspectPrioritiesMutating": true,
70+
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
71+
"@aws-cdk/core:checkSecretUsage": true,
72+
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
73+
"@aws-cdk/core:enablePartitionLiterals": true,
74+
"@aws-cdk/core:explicitStackTags": true,
75+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
76+
"@aws-cdk/core:target-partitions": [
77+
"aws",
78+
"aws-cn"
79+
],
80+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
81+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
82+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
83+
"@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true
84+
},
85+
"watch": {
86+
"exclude": [
87+
"README.md",
88+
"cdk*.json",
89+
"**/*.d.ts",
90+
"**/*.js",
91+
"tsconfig.json",
92+
"package*.json",
93+
"yarn.lock",
94+
"node_modules",
95+
"test"
96+
],
97+
"include": [
98+
"**"
99+
]
100+
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"appName": "java-springboot-ecs-cdk",
3+
"healthCheckPath": "/health",
4+
"imageName": "java-springboot",
5+
"language": "java",
6+
"port": 8080
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"appName": "nodejs-express-ecs-cdk",
3+
"healthCheckPath": "/health",
4+
"imageName": "nodejs-express",
5+
"language": "nodejs",
6+
"port": 3000
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"appName": "python-django-ecs-cdk",
3+
"healthCheckPath": "/health",
4+
"imageName": "python-django",
5+
"language": "python",
6+
"port": 8000
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"appName": "python-flask-ecs-cdk",
3+
"healthCheckPath": "/health",
4+
"imageName": "python-flask",
5+
"language": "python",
6+
"port": 5000
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bin": {
3+
"cdk": "bin/cdk.js"
4+
},
5+
"dependencies": {
6+
"aws-cdk-lib": "2.215.0",
7+
"constructs": "^10.0.0"
8+
},
9+
"devDependencies": {
10+
"@types/node": "22.7.9",
11+
"aws-cdk": "2.1030.0",
12+
"ts-node": "^10.9.2",
13+
"typescript": "~5.6.3"
14+
},
15+
"name": "cdk",
16+
"scripts": {
17+
"build": "tsc",
18+
"cdk": "cdk",
19+
"watch": "tsc -w"
20+
},
21+
"version": "0.1.0"
22+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true,
4+
"declaration": true,
5+
"experimentalDecorators": true,
6+
"inlineSourceMap": true,
7+
"inlineSources": true,
8+
"lib": [
9+
"es2022"
10+
],
11+
"module": "NodeNext",
12+
"moduleResolution": "NodeNext",
13+
"noFallthroughCasesInSwitch": false,
14+
"noImplicitAny": true,
15+
"noImplicitReturns": true,
16+
"noImplicitThis": true,
17+
"noUnusedLocals": false,
18+
"noUnusedParameters": false,
19+
"skipLibCheck": true,
20+
"strict": true,
21+
"strictNullChecks": true,
22+
"strictPropertyInitialization": false,
23+
"target": "ES2022",
24+
"typeRoots": [
25+
"./node_modules/@types"
26+
]
27+
},
28+
"exclude": [
29+
"node_modules",
30+
"cdk.out"
31+
]
32+
}

0 commit comments

Comments
 (0)