generated from szikszail/npm-package
/
secretsmanager.ts
55 lines (51 loc) · 1.79 KB
/
secretsmanager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Match, Matcher } from "aws-cdk-lib/assertions";
import { CfnSecret } from "aws-cdk-lib/aws-secretsmanager";
import { AdvancedTemplate } from "./advanced-template";
import { RemovableResource } from "./resource";
/**
* Represents a SecrestManager Secret test construct.
* @see {@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.CfnSecret.html}
*/
export class Secret extends RemovableResource {
constructor(template: AdvancedTemplate, props?: any) {
super(CfnSecret.CFN_RESOURCE_TYPE_NAME, template, props);
}
/**
* Adds a matching secret string generation template.
* @param key The whole or a partial key of the secret.
* @param template The whole or a partial template to generate the string, or a matcher.
* @returns
*/
public asGeneratedSecretString(key: string, template?: string | Matcher) {
const generatedSecretString: any = {
GenerateStringKey: Match.stringLikeRegexp(key),
};
if (template) {
if (typeof template === 'string') {
generatedSecretString.SecretStringTemplate = Match.stringLikeRegexp(template);
} else {
generatedSecretString.SecretStringTemplate = template;
}
}
this.withProperty('GenerateSecretString', Match.objectLike(generatedSecretString));
return this;
}
/**
* Adds a matching secret string value.
* @param value The whole or a partial value of the secret or a matcher.
* @returns
*/
public withSecretString(value: string | Matcher) {
this.withProperty('SecretString', value);
return this;
}
/**
* Adds a matching secret string name.
* @param value The whole or a partial name of the secret or a matcher.
* @returns
*/
public withName(name: string | Matcher) {
this.withProperty('Name', name);
return this;
}
}