Skip to content

Commit

Permalink
feat: refactor and update resource prefix aspect (#42)
Browse files Browse the repository at this point in the history
* Refactor and update resource prefix aspect

* Remove empty CFN stage prefixer

* Fix dependency versions after bumping cdk verison

* Cleanup tests for cfn prefixers

Co-authored-by: Stephen Robinson <[email protected]>
  • Loading branch information
maddocash and stephenrob authored Feb 11, 2022
1 parent 7386401 commit ed85e88
Show file tree
Hide file tree
Showing 21 changed files with 538 additions and 889 deletions.
48 changes: 24 additions & 24 deletions examples/container-lambda-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/container-lambda-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"@aws-cdk/core": "1.143.0",
"@aws-cdk/aws-ec2": "1.143.0",
"@aws-cdk/aws-sns": "1.143.0",
"@aws-cdk/aws-iam": "1.143.0",
"@aws-cdk/aws-lambda": "1.143.0",
"cdk-ecr-deployment": "1.0.2",
"source-map-support": "^0.5.16"
}
Expand Down
48 changes: 24 additions & 24 deletions examples/simple-authenticated-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions examples/simple-lambda-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CfnApi } from "@aws-cdk/aws-apigatewayv2";
import { IConstruct } from "@aws-cdk/core";
import { IConstruct, CfnResource, Annotations } from "@aws-cdk/core";
import {
CfnResourcePrefixer,
CfnResourcePrefixerBase,
Expand All @@ -10,9 +10,11 @@ export class Apigatewayv2CfnApiPrefixer
implements CfnResourcePrefixer
{
constructor(node: IConstruct, resourcePrefix: string) {
if (!(node instanceof CfnApi)) {
throw new Error(
"Specified node is not an instance of CfnApi and cannot be prefixed using this prefixer"
if (
!((node as CfnResource).cfnResourceType === CfnApi.CFN_RESOURCE_TYPE_NAME)
) {
Annotations.of(node).addError(
"Node is not a CfnApi and cannot be prefixed using this prefixer"
);
}
super(node, resourcePrefix);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CfnTable } from "@aws-cdk/aws-dynamodb";
import { IConstruct } from "@aws-cdk/core";
import { IConstruct, CfnResource, Annotations } from "@aws-cdk/core";
import {
CfnResourcePrefixer,
CfnResourcePrefixerBase,
Expand All @@ -10,9 +10,14 @@ export class DynamoDbCfnTablePrefixer
implements CfnResourcePrefixer
{
constructor(node: IConstruct, resourcePrefix: string) {
if (!(node instanceof CfnTable)) {
throw new Error(
"Specified node is not an instance of CfnTable and cannot be prefixed using this prefixer"
if (
!(
(node as CfnResource).cfnResourceType ===
CfnTable.CFN_RESOURCE_TYPE_NAME
)
) {
Annotations.of(node).addError(
"Node is not a CfnTable and cannot be prefixed using this prefixer"
);
}
super(node, resourcePrefix);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CfnSecurityGroup } from "@aws-cdk/aws-ec2";
import { IConstruct } from "@aws-cdk/core";
import { IConstruct, CfnResource, Annotations } from "@aws-cdk/core";
import {
CfnResourcePrefixer,
CfnResourcePrefixerBase,
Expand All @@ -10,9 +10,14 @@ export class Ec2CfnSecurityGroupPrefixer
implements CfnResourcePrefixer
{
constructor(node: IConstruct, resourcePrefix: string) {
if (!(node instanceof CfnSecurityGroup)) {
throw new Error(
"Specified node is not an instance of CfnSecurityGroup and cannot be prefixed using this prefixer"
if (
!(
(node as CfnResource).cfnResourceType ===
CfnSecurityGroup.CFN_RESOURCE_TYPE_NAME
)
) {
Annotations.of(node).addError(
"Node is not a CfnSecurityGroup and cannot be prefixed using this prefixer"
);
}
super(node, resourcePrefix);
Expand Down
Loading

0 comments on commit ed85e88

Please sign in to comment.