Skip to content

Commit

Permalink
chore(all code): address deprecated api (#892)
Browse files Browse the repository at this point in the history
* Change AddDependsOn to AddDependency

* Remove originAccessIdentityName

* Remove ssm string parameter Type references

* Removed PRIVATE_WITH_NAT

* Remove references to VpcProps.cidr

* Remove duplicate ec2 import

* Remove several duplicate import ec2 lines

* One more VpcProps.cidr reference
  • Loading branch information
biffgaut authored Feb 8, 2023
1 parent e6e833a commit 902c97c
Show file tree
Hide file tree
Showing 45 changed files with 93 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class AlbToFargate extends Construct {
if (newListener && this.listener) {
const levelOneListener = this.listener.node.defaultChild as CfnListener;
const cfnTargetGroup = newTargetGroup.node.defaultChild as CfnTargetGroup;
levelOneListener.addDependsOn(cfnTargetGroup);
levelOneListener.addDependency(cfnTargetGroup);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import * as cdk from "aws-cdk-lib";
import '@aws-cdk/assert/jest';
import * as defaults from '@aws-solutions-constructs/core';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('Test new vpc, load balancer, service', () => {
// An environment with region is required to enable logging on an ALB
Expand Down Expand Up @@ -275,7 +276,7 @@ test('Test new vpc, load balancer, service - custom VPC Props', () => {
listenerProps: {
protocol: 'HTTP'
},
vpcProps: { cidr: testCidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(testCidr) },
};

new AlbToFargate(stack, 'test-construct', testProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class AlbToLambda extends Construct {
if (newListener && this.listener) {
const levelOneListener = this.listener.node.defaultChild as CfnListener;
const cfnTargetGroup = newTargetGroup.node.defaultChild as CfnTargetGroup;
levelOneListener.addDependsOn(cfnTargetGroup);
levelOneListener.addDependency(cfnTargetGroup);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class CloudFrontToMediaStore extends Construct {
Resource: `arn:${Aws.PARTITION}:mediastore:${Aws.REGION}:${Aws.ACCOUNT_ID}:container/${Aws.STACK_NAME}/*`,
Condition: {
StringEquals: {
'aws:UserAgent': this.cloudFrontOriginAccessIdentity.originAccessIdentityName
'aws:UserAgent': this.cloudFrontOriginAccessIdentity.originAccessIdentityId
},
Bool: {
'aws:SecureTransport': 'true'
Expand All @@ -127,7 +127,7 @@ export class CloudFrontToMediaStore extends Construct {
};

const userAgentHeader: Record<string, string> = {
'User-Agent': this.cloudFrontOriginAccessIdentity.originAccessIdentityName
'User-Agent': this.cloudFrontOriginAccessIdentity.originAccessIdentityId
};

if (cloudFrontDistributionProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as cdk from "aws-cdk-lib";
import { FargateToDynamoDB } from "../lib";
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('New service/new table, public API, new VPC', () => {
const stack = new cdk.Stack();
Expand All @@ -30,7 +31,7 @@ test('New service/new table, public API, new VPC', () => {
const construct = new FargateToDynamoDB(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -168,7 +169,7 @@ test('New service/new table, private API, new VPC', () => {
new FargateToDynamoDB(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
dynamoTableProps: {
tableName,
partitionKey: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as cdk from "aws-cdk-lib";
import { FargateToEventbridge } from "../lib";
import * as events from 'aws-cdk-lib/aws-events';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const clusterName = "custom-cluster-name";
const containerName = "custom-container-name";
Expand Down Expand Up @@ -159,7 +160,7 @@ test('Check for IAM put events policy for default event bus', () => {
new FargateToEventbridge(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: testCidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(testCidr) },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -268,7 +269,7 @@ test('Check for custom ARN resource', () => {
new FargateToEventbridge(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: testCidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(testCidr) },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -323,7 +324,7 @@ test('Check for an existing event bus', () => {
const construct = new FargateToEventbridge(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: testCidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(testCidr) },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -353,7 +354,7 @@ function createFargateConstructWithNewResources(stack: cdk.Stack, publicApi: boo
return new FargateToEventbridge(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: testCidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(testCidr) },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FargateToKinesisFirehose } from "../lib";
import * as ecs from 'aws-cdk-lib/aws-ecs';
import { Match, Template } from "aws-cdk-lib/assertions";
import { GetTestFirehoseDestination } from './test-helper';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('New service/new bucket, public API, new VPC', () => {
const stack = new cdk.Stack();
Expand All @@ -31,7 +32,7 @@ test('New service/new bucket, public API, new VPC', () => {
const construct = new FargateToKinesisFirehose(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -142,7 +143,7 @@ test('New service/new bucket, private API, new VPC', () => {
new FargateToKinesisFirehose(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
existingKinesisFirehose: destination.kinesisFirehose
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FargateToKinesisFirehose } from "../lib";
import { generateIntegStackName, suppressAutoDeleteHandlerWarnings } from '@aws-solutions-constructs/core';
import * as ecs from "aws-cdk-lib/aws-ecs";
import { GetTestFirehoseDestination } from './test-helper';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const app = new App();
const stack = new Stack(app, generateIntegStackName(__filename));
Expand All @@ -29,7 +30,7 @@ new FargateToKinesisFirehose(stack, 'test-fargate-kinesisstreams', {
image: ecs.ContainerImage.fromRegistry('nginx')
},
vpcProps: {
cidr: '10.100.0.0/16'
ipAddresses: ec2.IpAddresses.cidr('10.100.0.0/16')
},
existingKinesisFirehose: destination.kinesisFirehose
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { App, Stack } from "aws-cdk-lib";
import { FargateToKinesisStreams } from "../lib";
import { generateIntegStackName } from '@aws-solutions-constructs/core';
import * as ecs from "aws-cdk-lib/aws-ecs";
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const app = new App();
const stack = new Stack(app, generateIntegStackName(__filename));
Expand All @@ -26,7 +27,7 @@ new FargateToKinesisStreams(stack, 'test-fargate-kinesisstreams', {
image: ecs.ContainerImage.fromRegistry('nginx')
},
vpcProps: {
cidr: '10.100.0.0/16'
ipAddresses: ec2.IpAddresses.cidr('10.100.0.0/16')
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as defaults from '@aws-solutions-constructs/core';
import * as cdk from "aws-cdk-lib";
import { FargateToOpenSearch } from "../lib";
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const DOMAIN_NAME = "solutions-construct-domain";
const COGNITO_DOMAIN_NAME = "cogn-solutions-construct-domain";
Expand All @@ -29,7 +30,7 @@ const deployStackWithNewResources = (stack: cdk.Stack, publicApi: boolean) => {
return new FargateToOpenSearch(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName: CLUSTER_NAME },
containerDefinitionProps: { CONTAINER_NAME },
fargateTaskDefinitionProps: { family: FAMILY_NAME },
Expand All @@ -45,7 +46,7 @@ test('Test domain and cognito domain name', () => {
new FargateToOpenSearch(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName: CLUSTER_NAME },
containerDefinitionProps: { CONTAINER_NAME },
fargateTaskDefinitionProps: { family: FAMILY_NAME },
Expand Down Expand Up @@ -177,7 +178,7 @@ test('Test custom environment variable name', () => {
new FargateToOpenSearch(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName: CLUSTER_NAME },
containerDefinitionProps: { CONTAINER_NAME },
fargateTaskDefinitionProps: { family: FAMILY_NAME },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as cdk from "aws-cdk-lib";
import { FargateToS3 } from "../lib";
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('New service/new bucket, public API, new VPC', () => {
// An environment with region is required to enable logging on an ALB
Expand All @@ -31,7 +32,7 @@ test('New service/new bucket, public API, new VPC', () => {
const construct = new FargateToS3(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -207,7 +208,7 @@ test('New service/new bucket, private API, new VPC', () => {
new FargateToS3(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
bucketProps: {
bucketName
},
Expand Down Expand Up @@ -319,7 +320,7 @@ test('Specify bad bucket permission', () => {
const props = {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
bucketProps: {
bucketName
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as cdk from "aws-cdk-lib";
import { FargateToSecretsmanager } from "../lib";
import * as ecs from 'aws-cdk-lib/aws-ecs';
import { buildSecretsManagerSecret } from '@aws-solutions-constructs/core';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const clusterName = "custom-cluster-name";
const containerName = "custom-container-name";
Expand All @@ -33,7 +34,7 @@ test('New service/new secret, public API, new VPC', () => {
const construct = new FargateToSecretsmanager(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(cidr) },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -146,7 +147,7 @@ test('New service/new secret, private API, new VPC', () => {
new FargateToSecretsmanager(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr(cidr) },
secretProps: {
secretName
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FargateToSns } from "../lib";
import * as kms from 'aws-cdk-lib/aws-kms';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('New service/new topic, public API, new VPC', () => {

Expand All @@ -34,7 +35,7 @@ test('New service/new topic, public API, new VPC', () => {
new FargateToSns(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: 'family-name' },
Expand Down Expand Up @@ -116,7 +117,7 @@ test('New service/new topic, private API, new VPC', () => {
new FargateToSns(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' }
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') }
});

expect(stack).toHaveResourceLike("AWS::ECS::Service", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FargateToSqs } from "../lib";
import * as kms from 'aws-cdk-lib/aws-kms';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

test('New service/new queue, dlq, public API, new VPC', () => {

Expand All @@ -34,7 +35,7 @@ test('New service/new queue, dlq, public API, new VPC', () => {
const construct = new FargateToSqs(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -166,7 +167,7 @@ test('New service/new queue, private API, new VPC', () => {
new FargateToSqs(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
deployDeadLetterQueue: false,
queuePermissions: ['Read']
});
Expand Down Expand Up @@ -494,7 +495,7 @@ test('Test bad queuePermissions', () => {
const props = {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
deployDeadLetterQueue: false,
queuePermissions: ['Reed'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as cdk from "aws-cdk-lib";
import { FargateToSsmstringparameter } from "../lib";
import * as ssm from 'aws-cdk-lib/aws-ssm';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

const allowedPattern = '.*';
const description = 'The value Foo';
Expand All @@ -35,7 +36,7 @@ test('New service/new parameter store, public API, new VPC', () => {
const construct = new FargateToSsmstringparameter(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
clusterProps: { clusterName },
containerDefinitionProps: { containerName },
fargateTaskDefinitionProps: { family: familyName },
Expand Down Expand Up @@ -172,7 +173,7 @@ test('New service/new parameter store, private API, new VPC', () => {
new FargateToSsmstringparameter(stack, 'test-construct', {
publicApi,
ecrRepositoryArn: defaults.fakeEcrRepoArn,
vpcProps: { cidr: '172.0.0.0/16' },
vpcProps: { ipAddresses: ec2.IpAddresses.cidr('172.0.0.0/16') },
stringParameterProps: {
parameterName,
stringValue
Expand Down
Loading

0 comments on commit 902c97c

Please sign in to comment.