diff --git a/SNAPSHOT_TESTING.md b/SNAPSHOT_TESTING.md index 26c80caca7..d3d5d13142 100644 --- a/SNAPSHOT_TESTING.md +++ b/SNAPSHOT_TESTING.md @@ -53,6 +53,92 @@ After adding the normalization to your tests, update your snapshots: npm test -- -u ``` +### 4. TypeScript Configuration for External Utilities + +When referencing the normalize-template utility from outside your project directory, you may need to update your `tsconfig.json` file: + +```json +{ + "compilerOptions": { + // Other options... + "rootDir": "../..", + "baseUrl": ".", + "paths": { + "../../test-utils/*": ["../../test-utils/*"] + } + }, + "exclude": [ + "node_modules", + "cdk.out", + "lib" + ], + "include": [ + "**/*.ts", + "../../test-utils/**/*.ts" + ] +} +``` + +Key changes: +- Set `rootDir` to include parent directories containing shared utilities +- Add `paths` mapping to resolve imports correctly +- Include the external utility files in the `include` section + +This configuration allows TypeScript to compile files that reference utilities outside your project directory. + +## What Gets Normalized + +The utility currently normalizes: + +1. **S3 Asset Keys**: Replaces asset hashes in S3Key properties + - Pattern with extension: `[64 hex chars].zip` → `NORMALIZED_ASSET_HASH.zip` + - Pattern without extension: `[64 hex chars]` → `NORMALIZED_ASSET_HASH` + +2. **Docker Image Digests**: Replaces image digests + - Pattern: `sha256:[digest]` → `NORMALIZED_IMAGE_DIGEST` + +## Adding New Test Files + +When creating new test files that use snapshot testing: + +1. Import the normalization utility +2. Apply it to your template before comparing with snapshots +3. Update your snapshots with the `-u` flag + +## Extending the Utility + +If you encounter other environment-specific values that need normalization, you can extend the utility at `typescript/test-utils/normalize-template.ts`. + +Example of adding a new normalization rule: + +```typescript +// Inside the normalizeValues function +if (key === 'NewPropertyToNormalize' && typeof obj[key] === 'string' && /pattern-to-match/.test(obj[key])) { + obj[key] = 'NORMALIZED_VALUE'; +} +``` + +## Troubleshooting + +If you're still seeing snapshot test failures: + +1. **Check for new patterns**: There might be new types of asset hashes or environment-specific values that need normalization +2. **Verify imports**: Make sure you're importing and using the utility correctly +3. **Check snapshot updates**: Ensure you've updated your snapshots after adding normalization +4. **TypeScript configuration**: If you're getting compilation errors about files outside your project directory, check your tsconfig.json settings + +## Best Practices + +1. **Always normalize before snapshot comparison**: This ensures consistent results +2. **Update snapshots deliberately**: Only use the `-u` flag when you expect changes +3. **Review snapshot diffs**: When updating snapshots, review the changes to ensure they're expected +4. **Keep the utility updated**: As new patterns emerge, add them to the normalization utility + +## Additional Resources + +- [Jest Snapshot Testing Documentation](https://jestjs.io/docs/snapshot-testing) +- [AWS CDK Testing Documentation](https://docs.aws.amazon.com/cdk/v2/guide/testing.html) + ## What Gets Normalized The utility currently normalizes: diff --git a/typescript/ec2-instance-connect-endpoint/.eslintrc.json b/typescript/ec2-instance-connect-endpoint/.eslintrc.json deleted file mode 100644 index da79cba46f..0000000000 --- a/typescript/ec2-instance-connect-endpoint/.eslintrc.json +++ /dev/null @@ -1,236 +0,0 @@ -// ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". -{ - "env": { - "jest": true, - "node": true - }, - "root": true, - "plugins": [ - "@typescript-eslint", - "import" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.dev.json", - "tsconfigRootDir": "typescript/ec2-instance-connect-endpoint" - }, - "extends": [ - "plugin:import/typescript" - ], - "settings": { - "import/parsers": { - "@typescript-eslint/parser": [ - ".ts", - ".tsx" - ] - }, - "import/resolver": { - "node": {}, - "typescript": { - "project": "./tsconfig.dev.json", - "alwaysTryTypes": true - } - } - }, - "ignorePatterns": [ - "*.js", - "*.d.ts", - "node_modules/", - "*.generated.ts", - "coverage", - "!.projenrc.ts", - "!projenrc/**/*.ts" - ], - "rules": { - "indent": [ - "off" - ], - "@typescript-eslint/indent": [ - "error", - 2 - ], - "quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "comma-dangle": [ - "error", - "always-multiline" - ], - "comma-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "no-multi-spaces": [ - "error", - { - "ignoreEOLComments": false - } - ], - "array-bracket-spacing": [ - "error", - "never" - ], - "array-bracket-newline": [ - "error", - "consistent" - ], - "object-curly-spacing": [ - "error", - "always" - ], - "object-curly-newline": [ - "error", - { - "multiline": true, - "consistent": true - } - ], - "object-property-newline": [ - "error", - { - "allowAllPropertiesOnSameLine": true - } - ], - "keyword-spacing": [ - "error" - ], - "brace-style": [ - "error", - "1tbs", - { - "allowSingleLine": true - } - ], - "space-before-blocks": [ - "error" - ], - "curly": [ - "error", - "multi-line", - "consistent" - ], - "@typescript-eslint/member-delimiter-style": [ - "error" - ], - "semi": [ - "error", - "always" - ], - "max-len": [ - "error", - { - "code": 150, - "ignoreUrls": true, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true, - "ignoreRegExpLiterals": true - } - ], - "quote-props": [ - "error", - "consistent-as-needed" - ], - "@typescript-eslint/no-require-imports": [ - "error" - ], - "import/no-extraneous-dependencies": [ - "error", - { - "devDependencies": [ - "**/test/**", - "**/build-tools/**", - ".projenrc.ts", - "projenrc/**/*.ts" - ], - "optionalDependencies": false, - "peerDependencies": true - } - ], - "import/no-unresolved": [ - "error" - ], - "import/order": [ - "warn", - { - "groups": [ - "builtin", - "external" - ], - "alphabetize": { - "order": "asc", - "caseInsensitive": true - } - } - ], - "no-duplicate-imports": [ - "error" - ], - "no-shadow": [ - "off" - ], - "@typescript-eslint/no-shadow": [ - "error" - ], - "key-spacing": [ - "error" - ], - "no-multiple-empty-lines": [ - "error" - ], - "@typescript-eslint/no-floating-promises": [ - "error" - ], - "no-return-await": [ - "off" - ], - "@typescript-eslint/return-await": [ - "error" - ], - "no-trailing-spaces": [ - "error" - ], - "dot-notation": [ - "error" - ], - "no-bitwise": [ - "error" - ], - "@typescript-eslint/member-ordering": [ - "error", - { - "default": [ - "public-static-field", - "public-static-method", - "protected-static-field", - "protected-static-method", - "private-static-field", - "private-static-method", - "field", - "constructor", - "method" - ] - } - ] - }, - "overrides": [ - { - "files": [ - ".projenrc.ts" - ], - "rules": { - "@typescript-eslint/no-require-imports": "off", - "import/no-extraneous-dependencies": "off" - } - } - ] -} diff --git a/typescript/ec2-instance-connect-endpoint/.npmignore b/typescript/ec2-instance-connect-endpoint/.npmignore deleted file mode 100644 index 79d65ac2b7..0000000000 --- a/typescript/ec2-instance-connect-endpoint/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". -/.projen/ -/test-reports/ -junit.xml -/coverage/ -permissions-backup.acl -/dist/changelog.md -/dist/version.txt -/.mergify.yml -/test/ -/tsconfig.dev.json -/src/ -!/lib/ -!/lib/**/*.js -!/lib/**/*.d.ts -dist -/tsconfig.json -/.github/ -/.vscode/ -/.idea/ -/.projenrc.js -tsconfig.tsbuildinfo -/.eslintrc.json -!.jsii -cdk.out -cdk.context.json -yarn-error.log diff --git a/typescript/ec2-instance-connect-endpoint/.npmrc b/typescript/ec2-instance-connect-endpoint/.npmrc new file mode 100644 index 0000000000..d67f374883 --- /dev/null +++ b/typescript/ec2-instance-connect-endpoint/.npmrc @@ -0,0 +1 @@ +node-linker=hoisted diff --git a/typescript/ec2-instance-connect-endpoint/README.md b/typescript/ec2-instance-connect-endpoint/README.md index c6ab8e28ab..a279c49b84 100644 --- a/typescript/ec2-instance-connect-endpoint/README.md +++ b/typescript/ec2-instance-connect-endpoint/README.md @@ -1,10 +1,8 @@ -# InstanceConnectEndpoint +# EC2 Instance Connect Endpoint -`InstanceConnectEndpoint` is a sample AWS CDK construct that allows you to build [EC2 Instance Connect Endpoint](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-using-eice.html) in your VPC with CDK custom resource. +This is a CDK construct that allows you to build [EC2 Instance Connect Endpoint](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-using-eice.html) in your VPC with a CDK custom resource. -This sample is generated with [projen](https://github.com/projen/projen) `awscdk-construct` project type so you can reference the `.projenrc.ts` and create your own CDK construct library like this with very little modification. - -# sample +## Usage ```ts // create an EIC Endpoint in an isolated subnet @@ -14,52 +12,54 @@ new InstanceConnectEndpoint(stack, 'EICEndpoint', { }); ``` -See full sample at [integ.default.ts](./src/integ.default.ts). +See full sample at [bin/app.ts](./bin/app.ts). -# deploy the default integration test +## Deploy the sample application ```sh -$ cd typescripts/ec2-instance-connect-endpoint -$ yarn install -# configure your AWS CLI -$ npx cdk diff -$ npx cdk deploy +# Install dependencies +npm install + +# Configure your AWS CLI +npm run build +npx cdk diff +npx cdk deploy ``` -On deployment completed, check the instance ID from the output: +On deployment completion, check the instance ID from the output: ``` integ-testing-eicendpoint.InstanceId = i-01d0f0c7ca761ff29 ``` -Now, connect it with AWS CLI: +Now, connect to it with AWS CLI: ```sh -$ aws ec2-instance-connect ssh --instance-id i-01d0f0c7ca761ff29 +aws ec2-instance-connect ssh --instance-id i-01d0f0c7ca761ff29 ``` -# `awssh` +## `awssh` Shortcut -Alternatively, you can create an `awssh` alias like this: +You can create an `awssh` alias for convenience: ```sh alias awssh='aws ec2-instance-connect ssh --instance-id' ``` -Now, you can just `awssh` into any ec2 instance behind the endpoint. +Now, you can quickly connect to any EC2 instance behind the endpoint: ```sh -$ awssh i-01d0f0c7ca761ff29 +awssh i-01d0f0c7ca761ff29 ``` -# run the tests +## Run tests ```sh -$ yarn test +npm test ``` -# clean up +## Clean up ```sh -$ npx cdk destroy -``` \ No newline at end of file +npx cdk destroy +``` diff --git a/typescript/ec2-instance-connect-endpoint/src/integ.default.ts b/typescript/ec2-instance-connect-endpoint/bin/app.ts similarity index 87% rename from typescript/ec2-instance-connect-endpoint/src/integ.default.ts rename to typescript/ec2-instance-connect-endpoint/bin/app.ts index 9f8d581753..c0052266f9 100644 --- a/typescript/ec2-instance-connect-endpoint/src/integ.default.ts +++ b/typescript/ec2-instance-connect-endpoint/bin/app.ts @@ -1,8 +1,9 @@ +#!/usr/bin/env node import { App, CfnOutput, Stack, aws_ec2 as ec2, } from 'aws-cdk-lib'; -import { InstanceConnectEndpoint } from './endpoint'; +import { InstanceConnectEndpoint } from '../src/endpoint'; export class IntegTesting { readonly stack: Stack[]; @@ -11,7 +12,7 @@ export class IntegTesting { const env = { region: process.env.CDK_DEFAULT_REGION, account: process.env.CDK_DEFAULT_ACCOUNT }; const stack = new Stack(app, 'integ-testing-eicendpoint', { env }); - const vpc = new ec2.Vpc(stack, 'Vpc', { subnetConfiguration: [{ cidrMask: 24, name: 'rds', subnetType: ec2. SubnetType. PRIVATE_ISOLATED }] }); + const vpc = new ec2.Vpc(stack, 'Vpc', { subnetConfiguration: [{ cidrMask: 24, name: 'rds', subnetType: ec2.SubnetType.PRIVATE_ISOLATED }] }); const instance = new ec2.Instance(stack, 'instance', { vpc, diff --git a/typescript/ec2-instance-connect-endpoint/cdk.json b/typescript/ec2-instance-connect-endpoint/cdk.json index f818b2a3da..604244024e 100644 --- a/typescript/ec2-instance-connect-endpoint/cdk.json +++ b/typescript/ec2-instance-connect-endpoint/cdk.json @@ -1,3 +1,44 @@ { - "app": "npx ts-node --prefer-ts-exts src/integ.default.ts" + "app": "npx ts-node --prefer-ts-exts bin/app.ts", + "watch": { + "include": [ + "**" + ], + "exclude": [ + "README.md", + "cdk*.json", + "**/*.d.ts", + "**/*.js", + "tsconfig.json", + "package*.json", + "yarn.lock", + "node_modules", + "test" + ] + }, + "context": { + "@aws-cdk/aws-lambda:recognizeLayerVersion": true, + "@aws-cdk/core:checkSecretUsage": true, + "@aws-cdk/core:target-partitions": [ + "aws", + "aws-cn" + ], + "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, + "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, + "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, + "@aws-cdk/aws-iam:minimizePolicies": true, + "@aws-cdk/core:validateSnapshotRemovalPolicy": true, + "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, + "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, + "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, + "@aws-cdk/aws-apigateway:disableCloudWatchRole": true, + "@aws-cdk/core:enablePartitionLiterals": true, + "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, + "@aws-cdk/aws-iam:standardizedServicePrincipals": true, + "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, + "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, + "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, + "@aws-cdk/aws-route53-patters:useFargateContainerForCustomResourceFunction": true, + "@aws-cdk/customresources:installLatestAwsSdkDefault": false + } } diff --git a/typescript/ec2-instance-connect-endpoint/package.json b/typescript/ec2-instance-connect-endpoint/package.json index cdcb68154f..373cdab559 100644 --- a/typescript/ec2-instance-connect-endpoint/package.json +++ b/typescript/ec2-instance-connect-endpoint/package.json @@ -5,42 +5,26 @@ "type": "git", "url": "https://github.com/aws-samples/aws-cdk-examples.git" }, + "bin": { + "ec2-instance-connect-endpoint": "bin/app.js" + }, "scripts": { "build": "tsc", "watch": "tsc -w", "test": "jest", "cdk": "cdk" }, - "author": { - "name": "Pahud Hsieh", - "email": "pahudnet@gmail.com" - }, "devDependencies": { "@types/jest": "^29.5.14", "@types/node": "^16", - "@typescript-eslint/eslint-plugin": "^5", - "@typescript-eslint/parser": "^5", - "aws-cdk": "2.85.0", - "aws-cdk-lib": "2.85.0", - "constructs": "10.0.5", - "eslint": "^8", - "jest": "^29.7.0", - "ts-jest": "^29.2.5", - "ts-node": "^10.9.2", - "typescript": "~5.6.3" - }, - "peerDependencies": { - "aws-cdk-lib": "^2.85.0", - "constructs": "^10.0.5" + "aws-cdk": "2.1007.0", + "jest": "^29.5.0", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" }, "dependencies": { - "@aws-cdk/aws-lambda-python-alpha": "^2.85.0-alpha.0", - "@aws-cdk/integ-tests-alpha": "^2.85.0-alpha.0" - }, - "keywords": [ - "cdk" - ], - "main": "lib/index.js", - "types": "lib/index.d.ts", - "license": "Apache-2.0" + "aws-cdk-lib": "2.189.1", + "constructs": "10.0.5" + } } diff --git a/typescript/ec2-instance-connect-endpoint/src/endpoint.ts b/typescript/ec2-instance-connect-endpoint/src/endpoint.ts index eba945b3a9..b310c8b2bf 100644 --- a/typescript/ec2-instance-connect-endpoint/src/endpoint.ts +++ b/typescript/ec2-instance-connect-endpoint/src/endpoint.ts @@ -1,5 +1,4 @@ import * as path from 'path'; -import * as lambdaPython from '@aws-cdk/aws-lambda-python-alpha'; import { Stack, aws_ec2 as ec2, @@ -8,6 +7,7 @@ import { custom_resources as cr, CustomResource, Duration, + aws_s3_assets as assets, } from 'aws-cdk-lib'; import { Construct } from 'constructs'; @@ -75,29 +75,28 @@ export class InstanceConnectEndpoint extends Construct { resources: ['*'], })); + // Create an asset for the Lambda code + const lambdaAsset = new assets.Asset(this, 'LambdaAsset', { + path: path.join(__dirname, '../lambda.d'), + }); + + // Common properties for Lambda functions const commonProps = { - entry: path.join(__dirname, '../lambda.d'), runtime: lambda.Runtime.PYTHON_3_9, - index: 'index.py', memorySize: 256, timeout: Duration.minutes(10), role, + code: lambda.Code.fromBucket(lambdaAsset.bucket, lambdaAsset.s3ObjectKey), }; - const onEventHandler = new lambdaPython.PythonFunction(this, 'onEventHandler', { + const onEventHandler = new lambda.Function(this, 'onEventHandler', { ...commonProps, - handler: 'on_event', - bundling: { - user: "1000", - }, - }); + handler: 'index.on_event', + }); - const isCompleteHandler = new lambdaPython.PythonFunction(this, 'isCompleteHandler', { + const isCompleteHandler = new lambda.Function(this, 'isCompleteHandler', { ...commonProps, - handler: 'is_complete', - bundling: { - user: "1000", - }, + handler: 'index.is_complete', }); const provider = new cr.Provider(this, 'Provider', { diff --git a/typescript/ec2-instance-connect-endpoint/test/__snapshots__/integ.default.test.ts.snap b/typescript/ec2-instance-connect-endpoint/test/__snapshots__/app.test.ts.snap similarity index 86% rename from typescript/ec2-instance-connect-endpoint/test/__snapshots__/integ.default.test.ts.snap rename to typescript/ec2-instance-connect-endpoint/test/__snapshots__/app.test.ts.snap index c403c7b7b2..5f0bc8eb81 100644 --- a/typescript/ec2-instance-connect-endpoint/test/__snapshots__/integ.default.test.ts.snap +++ b/typescript/ec2-instance-connect-endpoint/test/__snapshots__/app.test.ts.snap @@ -3,206 +3,126 @@ exports[`default validation 1`] = ` { "Mappings": { - "DefaultCrNodeVersionMap": { + "LatestNodeRuntimeMap": { "af-south-1": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-east-1": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-northeast-1": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-northeast-2": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-northeast-3": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-south-1": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-south-2": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-southeast-1": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-southeast-2": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, "ap-southeast-3": { - "value": "nodejs16.x", + "value": "nodejs20.x", }, - "ca-central-1": { - "value": "nodejs16.x", - }, - "cn-north-1": { - "value": "nodejs16.x", - }, - "cn-northwest-1": { - "value": "nodejs16.x", - }, - "eu-central-1": { - "value": "nodejs16.x", - }, - "eu-central-2": { - "value": "nodejs16.x", - }, - "eu-north-1": { - "value": "nodejs16.x", - }, - "eu-south-1": { - "value": "nodejs16.x", - }, - "eu-south-2": { - "value": "nodejs16.x", - }, - "eu-west-1": { - "value": "nodejs16.x", - }, - "eu-west-2": { - "value": "nodejs16.x", - }, - "eu-west-3": { - "value": "nodejs16.x", - }, - "me-central-1": { - "value": "nodejs16.x", - }, - "me-south-1": { - "value": "nodejs16.x", - }, - "sa-east-1": { - "value": "nodejs16.x", - }, - "us-east-1": { - "value": "nodejs16.x", - }, - "us-east-2": { - "value": "nodejs16.x", - }, - "us-gov-east-1": { - "value": "nodejs16.x", - }, - "us-gov-west-1": { - "value": "nodejs16.x", - }, - "us-iso-east-1": { - "value": "nodejs14.x", - }, - "us-iso-west-1": { - "value": "nodejs14.x", - }, - "us-isob-east-1": { - "value": "nodejs14.x", - }, - "us-west-1": { - "value": "nodejs16.x", - }, - "us-west-2": { - "value": "nodejs16.x", - }, - }, - "ServiceprincipalMap": { - "af-south-1": { - "states": "states.af-south-1.amazonaws.com", - }, - "ap-east-1": { - "states": "states.ap-east-1.amazonaws.com", - }, - "ap-northeast-1": { - "states": "states.ap-northeast-1.amazonaws.com", - }, - "ap-northeast-2": { - "states": "states.ap-northeast-2.amazonaws.com", + "ap-southeast-4": { + "value": "nodejs20.x", }, - "ap-northeast-3": { - "states": "states.ap-northeast-3.amazonaws.com", - }, - "ap-south-1": { - "states": "states.ap-south-1.amazonaws.com", - }, - "ap-south-2": { - "states": "states.ap-south-2.amazonaws.com", - }, - "ap-southeast-1": { - "states": "states.ap-southeast-1.amazonaws.com", - }, - "ap-southeast-2": { - "states": "states.ap-southeast-2.amazonaws.com", + "ap-southeast-5": { + "value": "nodejs20.x", }, - "ap-southeast-3": { - "states": "states.ap-southeast-3.amazonaws.com", + "ap-southeast-7": { + "value": "nodejs20.x", }, "ca-central-1": { - "states": "states.ca-central-1.amazonaws.com", + "value": "nodejs20.x", + }, + "ca-west-1": { + "value": "nodejs20.x", }, "cn-north-1": { - "states": "states.cn-north-1.amazonaws.com", + "value": "nodejs20.x", }, "cn-northwest-1": { - "states": "states.cn-northwest-1.amazonaws.com", + "value": "nodejs20.x", }, "eu-central-1": { - "states": "states.eu-central-1.amazonaws.com", + "value": "nodejs20.x", }, "eu-central-2": { - "states": "states.eu-central-2.amazonaws.com", + "value": "nodejs20.x", + }, + "eu-isoe-west-1": { + "value": "nodejs18.x", }, "eu-north-1": { - "states": "states.eu-north-1.amazonaws.com", + "value": "nodejs20.x", }, "eu-south-1": { - "states": "states.eu-south-1.amazonaws.com", + "value": "nodejs20.x", }, "eu-south-2": { - "states": "states.eu-south-2.amazonaws.com", + "value": "nodejs20.x", }, "eu-west-1": { - "states": "states.eu-west-1.amazonaws.com", + "value": "nodejs20.x", }, "eu-west-2": { - "states": "states.eu-west-2.amazonaws.com", + "value": "nodejs20.x", }, "eu-west-3": { - "states": "states.eu-west-3.amazonaws.com", + "value": "nodejs20.x", + }, + "il-central-1": { + "value": "nodejs20.x", }, "me-central-1": { - "states": "states.me-central-1.amazonaws.com", + "value": "nodejs20.x", }, "me-south-1": { - "states": "states.me-south-1.amazonaws.com", + "value": "nodejs20.x", + }, + "mx-central-1": { + "value": "nodejs20.x", }, "sa-east-1": { - "states": "states.sa-east-1.amazonaws.com", + "value": "nodejs20.x", }, "us-east-1": { - "states": "states.us-east-1.amazonaws.com", + "value": "nodejs20.x", }, "us-east-2": { - "states": "states.us-east-2.amazonaws.com", + "value": "nodejs20.x", }, "us-gov-east-1": { - "states": "states.us-gov-east-1.amazonaws.com", + "value": "nodejs20.x", }, "us-gov-west-1": { - "states": "states.us-gov-west-1.amazonaws.com", + "value": "nodejs20.x", }, "us-iso-east-1": { - "states": "states.amazonaws.com", + "value": "nodejs18.x", }, "us-iso-west-1": { - "states": "states.amazonaws.com", + "value": "nodejs18.x", }, "us-isob-east-1": { - "states": "states.amazonaws.com", + "value": "nodejs18.x", }, "us-west-1": { - "states": "states.us-west-1.amazonaws.com", + "value": "nodejs20.x", }, "us-west-2": { - "states": "states.us-west-2.amazonaws.com", + "value": "nodejs20.x", }, }, }, @@ -280,7 +200,7 @@ exports[`default validation 1`] = ` }, "Runtime": { "Fn::FindInMap": [ - "DefaultCrNodeVersionMap", + "LatestNodeRuntimeMap", { "Ref": "AWS::Region", }, @@ -352,6 +272,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointonEventHandlerC2E1F5F2", + "Arn", + ], + }, + }, { "Action": "lambda:InvokeFunction", "Effect": "Allow", @@ -378,6 +308,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointisCompleteHandler0273707A", + "Arn", + ], + }, + }, ], "Version": "2012-10-17", }, @@ -431,7 +371,7 @@ exports[`default validation 1`] = ` }, "Runtime": { "Fn::FindInMap": [ - "DefaultCrNodeVersionMap", + "LatestNodeRuntimeMap", { "Ref": "AWS::Region", }, @@ -503,6 +443,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointonEventHandlerC2E1F5F2", + "Arn", + ], + }, + }, { "Action": "lambda:InvokeFunction", "Effect": "Allow", @@ -529,6 +479,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointisCompleteHandler0273707A", + "Arn", + ], + }, + }, { "Action": "states:StartExecution", "Effect": "Allow", @@ -586,7 +546,7 @@ exports[`default validation 1`] = ` }, "Runtime": { "Fn::FindInMap": [ - "DefaultCrNodeVersionMap", + "LatestNodeRuntimeMap", { "Ref": "AWS::Region", }, @@ -658,6 +618,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointonEventHandlerC2E1F5F2", + "Arn", + ], + }, + }, { "Action": "lambda:InvokeFunction", "Effect": "Allow", @@ -684,6 +654,16 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": "lambda:GetFunction", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EICEndpointisCompleteHandler0273707A", + "Arn", + ], + }, + }, ], "Version": "2012-10-17", }, @@ -724,6 +704,22 @@ exports[`default validation 1`] = ` ], ], }, + "LoggingConfiguration": { + "Destinations": [ + { + "CloudWatchLogsLogGroup": { + "LogGroupArn": { + "Fn::GetAtt": [ + "EICEndpointProviderwaiterstatemachineLogGroupA14674E7", + "Arn", + ], + }, + }, + }, + ], + "IncludeExecutionData": false, + "Level": "ERROR", + }, "RoleArn": { "Fn::GetAtt": [ "EICEndpointProviderwaiterstatemachineRole5E284D23", @@ -733,6 +729,26 @@ exports[`default validation 1`] = ` }, "Type": "AWS::StepFunctions::StateMachine", }, + "EICEndpointProviderwaiterstatemachineLogGroupA14674E7": { + "DeletionPolicy": "Retain", + "Properties": { + "LogGroupName": { + "Fn::Join": [ + "", + [ + "/aws/vendedlogs/states/waiter-state-machine-", + { + "Ref": "EICEndpointProviderframeworkisCompleteB1442B18", + }, + "-c8d3e609467293bed52b842a64c4ccf79555d8f837", + ], + ], + }, + "RetentionInDays": 731, + }, + "Type": "AWS::Logs::LogGroup", + "UpdateReplacePolicy": "Retain", + }, "EICEndpointProviderwaiterstatemachineRole5E284D23": { "Properties": { "AssumeRolePolicyDocument": { @@ -741,15 +757,7 @@ exports[`default validation 1`] = ` "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -814,6 +822,22 @@ exports[`default validation 1`] = ` }, ], }, + { + "Action": [ + "logs:CreateLogDelivery", + "logs:CreateLogStream", + "logs:GetLogDelivery", + "logs:UpdateLogDelivery", + "logs:DeleteLogDelivery", + "logs:ListLogDeliveries", + "logs:PutLogEvents", + "logs:PutResourcePolicy", + "logs:DescribeResourcePolicies", + "logs:DescribeLogGroups", + ], + "Effect": "Allow", + "Resource": "*", + }, ], "Version": "2012-10-17", }, diff --git a/typescript/ec2-instance-connect-endpoint/test/integ.default.test.ts b/typescript/ec2-instance-connect-endpoint/test/app.test.ts similarity index 89% rename from typescript/ec2-instance-connect-endpoint/test/integ.default.test.ts rename to typescript/ec2-instance-connect-endpoint/test/app.test.ts index 5350884124..9dc86c7291 100644 --- a/typescript/ec2-instance-connect-endpoint/test/integ.default.test.ts +++ b/typescript/ec2-instance-connect-endpoint/test/app.test.ts @@ -1,5 +1,5 @@ import { Template } from 'aws-cdk-lib/assertions'; -import { IntegTesting } from '../src/integ.default'; +import { IntegTesting } from '../bin/app'; import { normalizeTemplate } from '../../test-utils/normalize-template'; test('default validation', () => { @@ -11,4 +11,4 @@ test('default validation', () => { // should match snapshot expect(normalizedTemplate).toMatchSnapshot(); }); -}); \ No newline at end of file +}); diff --git a/typescript/ec2-instance-connect-endpoint/tsconfig.json b/typescript/ec2-instance-connect-endpoint/tsconfig.json index dc6a7b03f6..7f8f927e0f 100644 --- a/typescript/ec2-instance-connect-endpoint/tsconfig.json +++ b/typescript/ec2-instance-connect-endpoint/tsconfig.json @@ -2,7 +2,9 @@ "compilerOptions": { "target": "ES2018", "module": "commonjs", - "lib": ["es2018"], + "lib": [ + "es2018" + ], "declaration": true, "strict": true, "noImplicitAny": true, @@ -17,8 +19,23 @@ "inlineSources": true, "experimentalDecorators": true, "strictPropertyInitialization": false, - "typeRoots": ["./node_modules/@types"], - "outDir": "dist" + "typeRoots": [ + "./node_modules/@types" + ], + "outDir": "lib", + "rootDir": "../..", + "baseUrl": ".", + "paths": { + "../../test-utils/*": ["../../test-utils/*"] + } }, - "exclude": ["node_modules", "cdk.out"] + "exclude": [ + "node_modules", + "cdk.out", + "lib" + ], + "include": [ + "**/*.ts", + "../../test-utils/**/*.ts" + ] }