Skip to content

Commit

Permalink
chore(secretsmanager): Remove unused secretName attribute
Browse files Browse the repository at this point in the history
In #10309, secretName was added to SecretAttributes, but given the ARN is always
required, it's fairly redundant. Removing to reduce public API surface area.

Not a breaking change, as #10309 has not yet been released.
  • Loading branch information
njlynch committed Sep 17, 2020
1 parent cb6fef8 commit b0ca374
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/@aws-cdk/aws-secretsmanager/lib/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ export interface SecretAttributes {
* The ARN of the secret in SecretsManager.
*/
readonly secretArn: string;

/**
* The name of the secret in SecretsManager.
*
* @default - the name is derived from the secretArn.
*/
readonly secretName?: string;
}

/**
Expand Down Expand Up @@ -286,7 +279,7 @@ export class Secret extends SecretBase {
class Import extends SecretBase {
public readonly encryptionKey = attrs.encryptionKey;
public readonly secretArn = attrs.secretArn;
public readonly secretName = parseSecretName(scope, attrs.secretArn, attrs.secretName);
public readonly secretName = parseSecretName(scope, attrs.secretArn);
protected readonly autoCreatePolicy = false;
}

Expand Down Expand Up @@ -601,9 +594,8 @@ export interface SecretStringGenerator {
readonly generateStringKey?: string;
}

/** Returns the secret name if defined, otherwise attempts to parse it from the ARN. */
export function parseSecretName(construct: IConstruct, secretArn: string, secretName?: string) {
if (secretName) { return secretName; }
/** Parses the secret name from the ARN. */
function parseSecretName(construct: IConstruct, secretArn: string) {
const resourceName = Stack.of(construct).parseArn(secretArn).resourceName;
if (resourceName) {
// Secret resource names are in the format `${secretName}-${SecretsManager suffix}`
Expand Down

0 comments on commit b0ca374

Please sign in to comment.