Skip to content

Commit 7f4f150

Browse files
authored
refactor: remove more duplicate enum values (#20982)
This is a follow-up to #19320: there are more duplicate enum values that need to be removed, in anticipation of a jsii release that will make these duplicate values illegal. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c20e2c4 commit 7f4f150

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

packages/@aws-cdk/aws-secretsmanager/lib/secret.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ export enum AttachmentTargetType {
684684
*
685685
* @deprecated use RDS_DB_INSTANCE instead
686686
*/
687-
INSTANCE = 'AWS::RDS::DBInstance',
687+
INSTANCE = 'deprecated_AWS::RDS::DBInstance',
688688

689689
/**
690690
* AWS::RDS::DBCluster
@@ -696,7 +696,7 @@ export enum AttachmentTargetType {
696696
*
697697
* @deprecated use RDS_DB_CLUSTER instead
698698
*/
699-
CLUSTER = 'AWS::RDS::DBCluster',
699+
CLUSTER = 'deprecated_AWS::RDS::DBCluster',
700700

701701
/**
702702
* AWS::RDS::DBProxy
@@ -797,7 +797,7 @@ export class SecretTargetAttachment extends SecretBase implements ISecretTargetA
797797
const attachment = new secretsmanager.CfnSecretTargetAttachment(this, 'Resource', {
798798
secretId: props.secret.secretArn,
799799
targetId: props.target.asSecretAttachmentTarget().targetId,
800-
targetType: props.target.asSecretAttachmentTarget().targetType,
800+
targetType: attachmentTargetTypeToString(props.target.asSecretAttachmentTarget().targetType),
801801
});
802802

803803
this.encryptionKey = props.secret.encryptionKey;
@@ -950,3 +950,22 @@ Object.defineProperty(Secret.prototype, SECRET_SYMBOL, {
950950
enumerable: false,
951951
writable: false,
952952
});
953+
954+
function attachmentTargetTypeToString(x: AttachmentTargetType): string {
955+
switch (x) {
956+
case AttachmentTargetType.RDS_DB_INSTANCE:
957+
case AttachmentTargetType.INSTANCE:
958+
return 'AWS::RDS::DBInstance';
959+
case AttachmentTargetType.RDS_DB_CLUSTER:
960+
case AttachmentTargetType.CLUSTER:
961+
return 'AWS::RDS::DBCluster';
962+
case AttachmentTargetType.RDS_DB_PROXY:
963+
return 'AWS::RDS::DBProxy';
964+
case AttachmentTargetType.REDSHIFT_CLUSTER:
965+
return 'AWS::Redshift::Cluster';
966+
case AttachmentTargetType.DOCDB_DB_INSTANCE:
967+
return 'AWS::DocDB::DBInstance';
968+
case AttachmentTargetType.DOCDB_DB_CLUSTER:
969+
return 'AWS::DocDB::DBCluster';
970+
}
971+
}

packages/@aws-cdk/aws-secretsmanager/test/secret.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ test('can attach a secret with attach()', () => {
11701170
secret.attach({
11711171
asSecretAttachmentTarget: () => ({
11721172
targetId: 'target-id',
1173-
targetType: 'target-type' as secretsmanager.AttachmentTargetType,
1173+
targetType: secretsmanager.AttachmentTargetType.DOCDB_DB_INSTANCE,
11741174
}),
11751175
});
11761176

@@ -1180,7 +1180,7 @@ test('can attach a secret with attach()', () => {
11801180
Ref: 'SecretA720EF05',
11811181
},
11821182
TargetId: 'target-id',
1183-
TargetType: 'target-type',
1183+
TargetType: 'AWS::DocDB::DBInstance',
11841184
});
11851185
});
11861186

@@ -1190,7 +1190,7 @@ test('throws when trying to attach a target multiple times to a secret', () => {
11901190
const target = {
11911191
asSecretAttachmentTarget: () => ({
11921192
targetId: 'target-id',
1193-
targetType: 'target-type' as secretsmanager.AttachmentTargetType,
1193+
targetType: secretsmanager.AttachmentTargetType.DOCDB_DB_INSTANCE,
11941194
}),
11951195
};
11961196
secret.attach(target);
@@ -1205,7 +1205,7 @@ test('add a rotation schedule to an attached secret', () => {
12051205
const attachedSecret = secret.attach({
12061206
asSecretAttachmentTarget: () => ({
12071207
targetId: 'target-id',
1208-
targetType: 'target-type' as secretsmanager.AttachmentTargetType,
1208+
targetType: secretsmanager.AttachmentTargetType.DOCDB_DB_INSTANCE,
12091209
}),
12101210
});
12111211
const rotationLambda = new lambda.Function(stack, 'Lambda', {

packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export enum CustomResourceProviderRuntime {
9999
*
100100
* @deprecated Use {@link NODEJS_14_X}
101101
*/
102-
NODEJS_12 = 'nodejs12.x',
102+
NODEJS_12 = 'deprecated_nodejs12.x',
103103

104104
/**
105105
* Node.js 14.x
@@ -255,7 +255,7 @@ export class CustomResourceProvider extends Construct {
255255
MemorySize: memory.toMebibytes(),
256256
Handler: `${ENTRYPOINT_FILENAME}.handler`,
257257
Role: role.getAtt('Arn'),
258-
Runtime: props.runtime,
258+
Runtime: customResourceProviderRuntimeToString(props.runtime),
259259
Environment: this.renderEnvironmentVariables(props.environment),
260260
Description: props.description ?? undefined,
261261
},
@@ -329,3 +329,15 @@ export class CustomResourceProvider extends Construct {
329329
return { Variables: variables };
330330
}
331331
}
332+
333+
function customResourceProviderRuntimeToString(x: CustomResourceProviderRuntime): string {
334+
switch (x) {
335+
case CustomResourceProviderRuntime.NODEJS_12:
336+
case CustomResourceProviderRuntime.NODEJS_12_X:
337+
return 'nodejs12.x';
338+
case CustomResourceProviderRuntime.NODEJS_14_X:
339+
return 'nodejs14.x';
340+
case CustomResourceProviderRuntime.NODEJS_16_X:
341+
return 'nodejs16.x';
342+
}
343+
}

0 commit comments

Comments
 (0)