@stacksjs/ts-cloud 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -13
- package/dist/aws/acm.d.ts +129 -0
- package/dist/aws/application-autoscaling.d.ts +282 -0
- package/dist/aws/bedrock.d.ts +2292 -0
- package/dist/aws/client.d.ts +79 -0
- package/dist/aws/cloudformation.d.ts +105 -0
- package/dist/aws/cloudfront.d.ts +265 -0
- package/dist/aws/cloudwatch-logs.d.ts +48 -0
- package/dist/aws/comprehend.d.ts +505 -0
- package/dist/aws/connect.d.ts +377 -0
- package/dist/aws/deploy-imap.d.ts +14 -0
- package/dist/aws/dynamodb.d.ts +176 -0
- package/dist/aws/ec2.d.ts +272 -0
- package/dist/aws/ecr.d.ts +149 -0
- package/dist/aws/ecs.d.ts +162 -0
- package/dist/aws/elasticache.d.ts +71 -0
- package/dist/aws/elbv2.d.ts +248 -0
- package/dist/aws/email.d.ts +175 -0
- package/dist/aws/eventbridge.d.ts +142 -0
- package/dist/aws/iam.d.ts +638 -0
- package/dist/aws/imap-server.d.ts +119 -0
- package/{src/aws/index.ts → dist/aws/index.d.ts} +62 -83
- package/{src/aws/kendra.ts → dist/aws/kendra.d.ts} +71 -386
- package/dist/aws/lambda.d.ts +232 -0
- package/dist/aws/opensearch.d.ts +87 -0
- package/dist/aws/personalize.d.ts +516 -0
- package/dist/aws/polly.d.ts +214 -0
- package/dist/aws/rds.d.ts +240 -0
- package/dist/aws/rekognition.d.ts +543 -0
- package/dist/aws/route53-domains.d.ts +113 -0
- package/dist/aws/route53.d.ts +215 -0
- package/dist/aws/s3.d.ts +212 -0
- package/dist/aws/scheduler.d.ts +140 -0
- package/dist/aws/secrets-manager.d.ts +170 -0
- package/dist/aws/ses.d.ts +288 -0
- package/dist/aws/setup-phone.d.ts +0 -0
- package/dist/aws/setup-sms.d.ts +115 -0
- package/dist/aws/sms.d.ts +304 -0
- package/dist/aws/smtp-server.d.ts +61 -0
- package/dist/aws/sns.d.ts +117 -0
- package/dist/aws/sqs.d.ts +65 -0
- package/dist/aws/ssm.d.ts +179 -0
- package/dist/aws/sts.d.ts +15 -0
- package/dist/aws/support.d.ts +104 -0
- package/dist/aws/test-imap.d.ts +0 -0
- package/dist/aws/textract.d.ts +403 -0
- package/dist/aws/transcribe.d.ts +60 -0
- package/dist/aws/translate.d.ts +358 -0
- package/dist/aws/voice.d.ts +219 -0
- package/dist/bin/cli.js +1724 -0
- package/dist/config.d.ts +7 -0
- package/dist/deploy/index.d.ts +2 -0
- package/dist/deploy/static-site-external-dns.d.ts +51 -0
- package/dist/deploy/static-site.d.ts +71 -0
- package/dist/dns/cloudflare.d.ts +52 -0
- package/dist/dns/godaddy.d.ts +38 -0
- package/dist/dns/index.d.ts +45 -0
- package/dist/dns/porkbun.d.ts +18 -0
- package/dist/dns/route53-adapter.d.ts +38 -0
- package/{src/dns/types.ts → dist/dns/types.d.ts} +26 -63
- package/dist/dns/validator.d.ts +78 -0
- package/dist/generators/index.d.ts +1 -0
- package/dist/generators/infrastructure.d.ts +30 -0
- package/{src/index.ts → dist/index.d.ts} +70 -93
- package/dist/index.js +7881 -0
- package/dist/push/apns.d.ts +60 -0
- package/dist/push/fcm.d.ts +117 -0
- package/dist/push/index.d.ts +14 -0
- package/dist/security/pre-deploy-scanner.d.ts +69 -0
- package/dist/ssl/acme-client.d.ts +67 -0
- package/dist/ssl/index.d.ts +2 -0
- package/dist/ssl/letsencrypt.d.ts +48 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/cli.d.ts +123 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/template.d.ts +23 -0
- package/package.json +8 -8
- package/bin/cli.ts +0 -133
- package/bin/commands/analytics.ts +0 -328
- package/bin/commands/api.ts +0 -379
- package/bin/commands/assets.ts +0 -221
- package/bin/commands/audit.ts +0 -501
- package/bin/commands/backup.ts +0 -682
- package/bin/commands/cache.ts +0 -294
- package/bin/commands/cdn.ts +0 -281
- package/bin/commands/config.ts +0 -202
- package/bin/commands/container.ts +0 -105
- package/bin/commands/cost.ts +0 -208
- package/bin/commands/database.ts +0 -401
- package/bin/commands/deploy.ts +0 -674
- package/bin/commands/domain.ts +0 -397
- package/bin/commands/email.ts +0 -423
- package/bin/commands/environment.ts +0 -285
- package/bin/commands/events.ts +0 -424
- package/bin/commands/firewall.ts +0 -145
- package/bin/commands/function.ts +0 -116
- package/bin/commands/generate.ts +0 -280
- package/bin/commands/git.ts +0 -139
- package/bin/commands/iam.ts +0 -464
- package/bin/commands/index.ts +0 -48
- package/bin/commands/init.ts +0 -120
- package/bin/commands/logs.ts +0 -148
- package/bin/commands/network.ts +0 -579
- package/bin/commands/notify.ts +0 -489
- package/bin/commands/queue.ts +0 -407
- package/bin/commands/scheduler.ts +0 -370
- package/bin/commands/secrets.ts +0 -54
- package/bin/commands/server.ts +0 -629
- package/bin/commands/shared.ts +0 -97
- package/bin/commands/ssl.ts +0 -138
- package/bin/commands/stack.ts +0 -325
- package/bin/commands/status.ts +0 -385
- package/bin/commands/storage.ts +0 -450
- package/bin/commands/team.ts +0 -96
- package/bin/commands/tunnel.ts +0 -489
- package/bin/commands/utils.ts +0 -202
- package/build.ts +0 -15
- package/cloud +0 -2
- package/src/aws/acm.ts +0 -768
- package/src/aws/application-autoscaling.ts +0 -845
- package/src/aws/bedrock.ts +0 -4074
- package/src/aws/client.ts +0 -878
- package/src/aws/cloudformation.ts +0 -896
- package/src/aws/cloudfront.ts +0 -1531
- package/src/aws/cloudwatch-logs.ts +0 -154
- package/src/aws/comprehend.ts +0 -839
- package/src/aws/connect.ts +0 -1056
- package/src/aws/deploy-imap.ts +0 -384
- package/src/aws/dynamodb.ts +0 -340
- package/src/aws/ec2.ts +0 -1385
- package/src/aws/ecr.ts +0 -621
- package/src/aws/ecs.ts +0 -615
- package/src/aws/elasticache.ts +0 -301
- package/src/aws/elbv2.ts +0 -942
- package/src/aws/email.ts +0 -928
- package/src/aws/eventbridge.ts +0 -248
- package/src/aws/iam.ts +0 -1689
- package/src/aws/imap-server.ts +0 -2100
- package/src/aws/lambda.ts +0 -786
- package/src/aws/opensearch.ts +0 -158
- package/src/aws/personalize.ts +0 -977
- package/src/aws/polly.ts +0 -559
- package/src/aws/rds.ts +0 -888
- package/src/aws/rekognition.ts +0 -846
- package/src/aws/route53-domains.ts +0 -359
- package/src/aws/route53.ts +0 -1046
- package/src/aws/s3.ts +0 -2318
- package/src/aws/scheduler.ts +0 -571
- package/src/aws/secrets-manager.ts +0 -769
- package/src/aws/ses.ts +0 -1081
- package/src/aws/setup-phone.ts +0 -104
- package/src/aws/setup-sms.ts +0 -580
- package/src/aws/sms.ts +0 -1735
- package/src/aws/smtp-server.ts +0 -531
- package/src/aws/sns.ts +0 -758
- package/src/aws/sqs.ts +0 -382
- package/src/aws/ssm.ts +0 -807
- package/src/aws/sts.ts +0 -92
- package/src/aws/support.ts +0 -391
- package/src/aws/test-imap.ts +0 -86
- package/src/aws/textract.ts +0 -780
- package/src/aws/transcribe.ts +0 -108
- package/src/aws/translate.ts +0 -641
- package/src/aws/voice.ts +0 -1379
- package/src/config.ts +0 -35
- package/src/deploy/index.ts +0 -7
- package/src/deploy/static-site-external-dns.ts +0 -906
- package/src/deploy/static-site.ts +0 -1125
- package/src/dns/godaddy.ts +0 -412
- package/src/dns/index.ts +0 -183
- package/src/dns/porkbun.ts +0 -362
- package/src/dns/route53-adapter.ts +0 -414
- package/src/dns/validator.ts +0 -369
- package/src/generators/index.ts +0 -5
- package/src/generators/infrastructure.ts +0 -1660
- package/src/push/apns.ts +0 -452
- package/src/push/fcm.ts +0 -506
- package/src/push/index.ts +0 -58
- package/src/ssl/acme-client.ts +0 -478
- package/src/ssl/index.ts +0 -7
- package/src/ssl/letsencrypt.ts +0 -747
- package/src/types.ts +0 -2
- package/src/utils/cli.ts +0 -398
- package/src/validation/index.ts +0 -5
- package/src/validation/template.ts +0 -405
- package/test/index.test.ts +0 -128
- package/tsconfig.json +0 -18
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AWS Secrets Manager Client
|
|
3
|
-
* Manages secrets using direct API calls
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { AWSClient } from './client'
|
|
7
|
-
|
|
8
|
-
export interface Secret {
|
|
9
|
-
ARN?: string
|
|
10
|
-
Name?: string
|
|
11
|
-
Description?: string
|
|
12
|
-
KmsKeyId?: string
|
|
13
|
-
RotationEnabled?: boolean
|
|
14
|
-
RotationLambdaARN?: string
|
|
15
|
-
RotationRules?: {
|
|
16
|
-
AutomaticallyAfterDays?: number
|
|
17
|
-
Duration?: string
|
|
18
|
-
ScheduleExpression?: string
|
|
19
|
-
}
|
|
20
|
-
LastRotatedDate?: string
|
|
21
|
-
LastChangedDate?: string
|
|
22
|
-
LastAccessedDate?: string
|
|
23
|
-
DeletedDate?: string
|
|
24
|
-
NextRotationDate?: string
|
|
25
|
-
Tags?: { Key: string, Value: string }[]
|
|
26
|
-
SecretVersionsToStages?: Record<string, string[]>
|
|
27
|
-
CreatedDate?: string
|
|
28
|
-
PrimaryRegion?: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface SecretValue {
|
|
32
|
-
ARN?: string
|
|
33
|
-
Name?: string
|
|
34
|
-
VersionId?: string
|
|
35
|
-
SecretBinary?: string
|
|
36
|
-
SecretString?: string
|
|
37
|
-
VersionStages?: string[]
|
|
38
|
-
CreatedDate?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface CreateSecretOptions {
|
|
42
|
-
Name: string
|
|
43
|
-
Description?: string
|
|
44
|
-
KmsKeyId?: string
|
|
45
|
-
SecretBinary?: string
|
|
46
|
-
SecretString?: string
|
|
47
|
-
Tags?: { Key: string, Value: string }[]
|
|
48
|
-
AddReplicaRegions?: { Region: string, KmsKeyId?: string }[]
|
|
49
|
-
ForceOverwriteReplicaSecret?: boolean
|
|
50
|
-
ClientRequestToken?: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface UpdateSecretOptions {
|
|
54
|
-
SecretId: string
|
|
55
|
-
Description?: string
|
|
56
|
-
KmsKeyId?: string
|
|
57
|
-
SecretBinary?: string
|
|
58
|
-
SecretString?: string
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface PutSecretValueOptions {
|
|
62
|
-
SecretId: string
|
|
63
|
-
SecretBinary?: string
|
|
64
|
-
SecretString?: string
|
|
65
|
-
VersionStages?: string[]
|
|
66
|
-
ClientRequestToken?: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface GetSecretValueOptions {
|
|
70
|
-
SecretId: string
|
|
71
|
-
VersionId?: string
|
|
72
|
-
VersionStage?: string
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface RotationRules {
|
|
76
|
-
AutomaticallyAfterDays?: number
|
|
77
|
-
Duration?: string
|
|
78
|
-
ScheduleExpression?: string
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Secrets Manager client using direct API calls
|
|
83
|
-
*/
|
|
84
|
-
export class SecretsManagerClient {
|
|
85
|
-
private client: AWSClient
|
|
86
|
-
private region: string
|
|
87
|
-
|
|
88
|
-
constructor(region: string = 'us-east-1', profile?: string) {
|
|
89
|
-
this.region = region
|
|
90
|
-
this.client = new AWSClient()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Create a new secret
|
|
95
|
-
*/
|
|
96
|
-
async createSecret(options: CreateSecretOptions): Promise<{
|
|
97
|
-
ARN?: string
|
|
98
|
-
Name?: string
|
|
99
|
-
VersionId?: string
|
|
100
|
-
ReplicationStatus?: { Region: string, Status: string, StatusMessage?: string }[]
|
|
101
|
-
}> {
|
|
102
|
-
const params: Record<string, any> = {
|
|
103
|
-
Name: options.Name,
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (options.Description) {
|
|
107
|
-
params.Description = options.Description
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (options.KmsKeyId) {
|
|
111
|
-
params.KmsKeyId = options.KmsKeyId
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (options.SecretBinary) {
|
|
115
|
-
params.SecretBinary = options.SecretBinary
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (options.SecretString) {
|
|
119
|
-
params.SecretString = options.SecretString
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (options.Tags && options.Tags.length > 0) {
|
|
123
|
-
params.Tags = options.Tags
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (options.AddReplicaRegions && options.AddReplicaRegions.length > 0) {
|
|
127
|
-
params.AddReplicaRegions = options.AddReplicaRegions
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (options.ForceOverwriteReplicaSecret !== undefined) {
|
|
131
|
-
params.ForceOverwriteReplicaSecret = options.ForceOverwriteReplicaSecret
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Generate a unique client request token if not provided
|
|
135
|
-
params.ClientRequestToken = options.ClientRequestToken || crypto.randomUUID()
|
|
136
|
-
|
|
137
|
-
const result = await this.client.request({
|
|
138
|
-
service: 'secretsmanager',
|
|
139
|
-
region: this.region,
|
|
140
|
-
method: 'POST',
|
|
141
|
-
path: '/',
|
|
142
|
-
headers: {
|
|
143
|
-
'X-Amz-Target': 'secretsmanager.CreateSecret',
|
|
144
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
145
|
-
},
|
|
146
|
-
body: JSON.stringify(params),
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
ARN: result.ARN,
|
|
151
|
-
Name: result.Name,
|
|
152
|
-
VersionId: result.VersionId,
|
|
153
|
-
ReplicationStatus: result.ReplicationStatus,
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Update an existing secret's metadata
|
|
159
|
-
*/
|
|
160
|
-
async updateSecret(options: UpdateSecretOptions): Promise<{
|
|
161
|
-
ARN?: string
|
|
162
|
-
Name?: string
|
|
163
|
-
VersionId?: string
|
|
164
|
-
}> {
|
|
165
|
-
const params: Record<string, any> = {
|
|
166
|
-
SecretId: options.SecretId,
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (options.Description) {
|
|
170
|
-
params.Description = options.Description
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (options.KmsKeyId) {
|
|
174
|
-
params.KmsKeyId = options.KmsKeyId
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (options.SecretBinary) {
|
|
178
|
-
params.SecretBinary = options.SecretBinary
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (options.SecretString) {
|
|
182
|
-
params.SecretString = options.SecretString
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const result = await this.client.request({
|
|
186
|
-
service: 'secretsmanager',
|
|
187
|
-
region: this.region,
|
|
188
|
-
method: 'POST',
|
|
189
|
-
path: '/',
|
|
190
|
-
headers: {
|
|
191
|
-
'X-Amz-Target': 'secretsmanager.UpdateSecret',
|
|
192
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
193
|
-
},
|
|
194
|
-
body: JSON.stringify(params),
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
ARN: result.ARN,
|
|
199
|
-
Name: result.Name,
|
|
200
|
-
VersionId: result.VersionId,
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Put a new version of a secret value
|
|
206
|
-
*/
|
|
207
|
-
async putSecretValue(options: PutSecretValueOptions): Promise<{
|
|
208
|
-
ARN?: string
|
|
209
|
-
Name?: string
|
|
210
|
-
VersionId?: string
|
|
211
|
-
VersionStages?: string[]
|
|
212
|
-
}> {
|
|
213
|
-
const params: Record<string, any> = {
|
|
214
|
-
SecretId: options.SecretId,
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (options.SecretBinary) {
|
|
218
|
-
params.SecretBinary = options.SecretBinary
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (options.SecretString) {
|
|
222
|
-
params.SecretString = options.SecretString
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (options.VersionStages && options.VersionStages.length > 0) {
|
|
226
|
-
params.VersionStages = options.VersionStages
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (options.ClientRequestToken) {
|
|
230
|
-
params.ClientRequestToken = options.ClientRequestToken
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const result = await this.client.request({
|
|
234
|
-
service: 'secretsmanager',
|
|
235
|
-
region: this.region,
|
|
236
|
-
method: 'POST',
|
|
237
|
-
path: '/',
|
|
238
|
-
headers: {
|
|
239
|
-
'X-Amz-Target': 'secretsmanager.PutSecretValue',
|
|
240
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
241
|
-
},
|
|
242
|
-
body: JSON.stringify(params),
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
ARN: result.ARN,
|
|
247
|
-
Name: result.Name,
|
|
248
|
-
VersionId: result.VersionId,
|
|
249
|
-
VersionStages: result.VersionStages,
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Get the value of a secret
|
|
255
|
-
*/
|
|
256
|
-
async getSecretValue(options: GetSecretValueOptions): Promise<SecretValue> {
|
|
257
|
-
const params: Record<string, any> = {
|
|
258
|
-
SecretId: options.SecretId,
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (options.VersionId) {
|
|
262
|
-
params.VersionId = options.VersionId
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (options.VersionStage) {
|
|
266
|
-
params.VersionStage = options.VersionStage
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const result = await this.client.request({
|
|
270
|
-
service: 'secretsmanager',
|
|
271
|
-
region: this.region,
|
|
272
|
-
method: 'POST',
|
|
273
|
-
path: '/',
|
|
274
|
-
headers: {
|
|
275
|
-
'X-Amz-Target': 'secretsmanager.GetSecretValue',
|
|
276
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
277
|
-
},
|
|
278
|
-
body: JSON.stringify(params),
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
return {
|
|
282
|
-
ARN: result.ARN,
|
|
283
|
-
Name: result.Name,
|
|
284
|
-
VersionId: result.VersionId,
|
|
285
|
-
SecretBinary: result.SecretBinary,
|
|
286
|
-
SecretString: result.SecretString,
|
|
287
|
-
VersionStages: result.VersionStages,
|
|
288
|
-
CreatedDate: result.CreatedDate,
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Describe a secret (metadata only)
|
|
294
|
-
*/
|
|
295
|
-
async describeSecret(secretId: string): Promise<Secret> {
|
|
296
|
-
const params: Record<string, any> = {
|
|
297
|
-
SecretId: secretId,
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const result = await this.client.request({
|
|
301
|
-
service: 'secretsmanager',
|
|
302
|
-
region: this.region,
|
|
303
|
-
method: 'POST',
|
|
304
|
-
path: '/',
|
|
305
|
-
headers: {
|
|
306
|
-
'X-Amz-Target': 'secretsmanager.DescribeSecret',
|
|
307
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
308
|
-
},
|
|
309
|
-
body: JSON.stringify(params),
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
return this.parseSecret(result)
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* List secrets
|
|
317
|
-
*/
|
|
318
|
-
async listSecrets(options?: {
|
|
319
|
-
MaxResults?: number
|
|
320
|
-
NextToken?: string
|
|
321
|
-
Filters?: { Key: string, Values: string[] }[]
|
|
322
|
-
SortOrder?: 'asc' | 'desc'
|
|
323
|
-
}): Promise<{
|
|
324
|
-
SecretList?: Secret[]
|
|
325
|
-
NextToken?: string
|
|
326
|
-
}> {
|
|
327
|
-
const params: Record<string, any> = {}
|
|
328
|
-
|
|
329
|
-
if (options?.MaxResults) {
|
|
330
|
-
params.MaxResults = options.MaxResults
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (options?.NextToken) {
|
|
334
|
-
params.NextToken = options.NextToken
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (options?.Filters && options.Filters.length > 0) {
|
|
338
|
-
params.Filters = options.Filters
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if (options?.SortOrder) {
|
|
342
|
-
params.SortOrder = options.SortOrder
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const result = await this.client.request({
|
|
346
|
-
service: 'secretsmanager',
|
|
347
|
-
region: this.region,
|
|
348
|
-
method: 'POST',
|
|
349
|
-
path: '/',
|
|
350
|
-
headers: {
|
|
351
|
-
'X-Amz-Target': 'secretsmanager.ListSecrets',
|
|
352
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
353
|
-
},
|
|
354
|
-
body: JSON.stringify(params),
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
return {
|
|
358
|
-
SecretList: result.SecretList?.map((s: any) => this.parseSecret(s)),
|
|
359
|
-
NextToken: result.NextToken,
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Delete a secret
|
|
365
|
-
*/
|
|
366
|
-
async deleteSecret(options: {
|
|
367
|
-
SecretId: string
|
|
368
|
-
RecoveryWindowInDays?: number
|
|
369
|
-
ForceDeleteWithoutRecovery?: boolean
|
|
370
|
-
}): Promise<{
|
|
371
|
-
ARN?: string
|
|
372
|
-
Name?: string
|
|
373
|
-
DeletionDate?: string
|
|
374
|
-
}> {
|
|
375
|
-
const params: Record<string, any> = {
|
|
376
|
-
SecretId: options.SecretId,
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (options.RecoveryWindowInDays !== undefined) {
|
|
380
|
-
params.RecoveryWindowInDays = options.RecoveryWindowInDays
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
if (options.ForceDeleteWithoutRecovery !== undefined) {
|
|
384
|
-
params.ForceDeleteWithoutRecovery = options.ForceDeleteWithoutRecovery
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const result = await this.client.request({
|
|
388
|
-
service: 'secretsmanager',
|
|
389
|
-
region: this.region,
|
|
390
|
-
method: 'POST',
|
|
391
|
-
path: '/',
|
|
392
|
-
headers: {
|
|
393
|
-
'X-Amz-Target': 'secretsmanager.DeleteSecret',
|
|
394
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
395
|
-
},
|
|
396
|
-
body: JSON.stringify(params),
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
ARN: result.ARN,
|
|
401
|
-
Name: result.Name,
|
|
402
|
-
DeletionDate: result.DeletionDate,
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Restore a deleted secret
|
|
408
|
-
*/
|
|
409
|
-
async restoreSecret(secretId: string): Promise<{
|
|
410
|
-
ARN?: string
|
|
411
|
-
Name?: string
|
|
412
|
-
}> {
|
|
413
|
-
const params: Record<string, any> = {
|
|
414
|
-
SecretId: secretId,
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const result = await this.client.request({
|
|
418
|
-
service: 'secretsmanager',
|
|
419
|
-
region: this.region,
|
|
420
|
-
method: 'POST',
|
|
421
|
-
path: '/',
|
|
422
|
-
headers: {
|
|
423
|
-
'X-Amz-Target': 'secretsmanager.RestoreSecret',
|
|
424
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
425
|
-
},
|
|
426
|
-
body: JSON.stringify(params),
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
return {
|
|
430
|
-
ARN: result.ARN,
|
|
431
|
-
Name: result.Name,
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Configure automatic rotation for a secret
|
|
437
|
-
*/
|
|
438
|
-
async rotateSecret(options: {
|
|
439
|
-
SecretId: string
|
|
440
|
-
ClientRequestToken?: string
|
|
441
|
-
RotationLambdaARN?: string
|
|
442
|
-
RotationRules?: RotationRules
|
|
443
|
-
RotateImmediately?: boolean
|
|
444
|
-
}): Promise<{
|
|
445
|
-
ARN?: string
|
|
446
|
-
Name?: string
|
|
447
|
-
VersionId?: string
|
|
448
|
-
}> {
|
|
449
|
-
const params: Record<string, any> = {
|
|
450
|
-
SecretId: options.SecretId,
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (options.ClientRequestToken) {
|
|
454
|
-
params.ClientRequestToken = options.ClientRequestToken
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (options.RotationLambdaARN) {
|
|
458
|
-
params.RotationLambdaARN = options.RotationLambdaARN
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
if (options.RotationRules) {
|
|
462
|
-
params.RotationRules = options.RotationRules
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (options.RotateImmediately !== undefined) {
|
|
466
|
-
params.RotateImmediately = options.RotateImmediately
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const result = await this.client.request({
|
|
470
|
-
service: 'secretsmanager',
|
|
471
|
-
region: this.region,
|
|
472
|
-
method: 'POST',
|
|
473
|
-
path: '/',
|
|
474
|
-
headers: {
|
|
475
|
-
'X-Amz-Target': 'secretsmanager.RotateSecret',
|
|
476
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
477
|
-
},
|
|
478
|
-
body: JSON.stringify(params),
|
|
479
|
-
})
|
|
480
|
-
|
|
481
|
-
return {
|
|
482
|
-
ARN: result.ARN,
|
|
483
|
-
Name: result.Name,
|
|
484
|
-
VersionId: result.VersionId,
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Cancel rotation for a secret
|
|
490
|
-
*/
|
|
491
|
-
async cancelRotateSecret(secretId: string): Promise<{
|
|
492
|
-
ARN?: string
|
|
493
|
-
Name?: string
|
|
494
|
-
}> {
|
|
495
|
-
const params: Record<string, any> = {
|
|
496
|
-
SecretId: secretId,
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
const result = await this.client.request({
|
|
500
|
-
service: 'secretsmanager',
|
|
501
|
-
region: this.region,
|
|
502
|
-
method: 'POST',
|
|
503
|
-
path: '/',
|
|
504
|
-
headers: {
|
|
505
|
-
'X-Amz-Target': 'secretsmanager.CancelRotateSecret',
|
|
506
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
507
|
-
},
|
|
508
|
-
body: JSON.stringify(params),
|
|
509
|
-
})
|
|
510
|
-
|
|
511
|
-
return {
|
|
512
|
-
ARN: result.ARN,
|
|
513
|
-
Name: result.Name,
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Get resource policy for a secret
|
|
519
|
-
*/
|
|
520
|
-
async getResourcePolicy(secretId: string): Promise<{
|
|
521
|
-
ARN?: string
|
|
522
|
-
Name?: string
|
|
523
|
-
ResourcePolicy?: string
|
|
524
|
-
}> {
|
|
525
|
-
const params: Record<string, any> = {
|
|
526
|
-
SecretId: secretId,
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
const result = await this.client.request({
|
|
530
|
-
service: 'secretsmanager',
|
|
531
|
-
region: this.region,
|
|
532
|
-
method: 'POST',
|
|
533
|
-
path: '/',
|
|
534
|
-
headers: {
|
|
535
|
-
'X-Amz-Target': 'secretsmanager.GetResourcePolicy',
|
|
536
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
537
|
-
},
|
|
538
|
-
body: JSON.stringify(params),
|
|
539
|
-
})
|
|
540
|
-
|
|
541
|
-
return {
|
|
542
|
-
ARN: result.ARN,
|
|
543
|
-
Name: result.Name,
|
|
544
|
-
ResourcePolicy: result.ResourcePolicy,
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Put resource policy for a secret
|
|
550
|
-
*/
|
|
551
|
-
async putResourcePolicy(options: {
|
|
552
|
-
SecretId: string
|
|
553
|
-
ResourcePolicy: string
|
|
554
|
-
BlockPublicPolicy?: boolean
|
|
555
|
-
}): Promise<{
|
|
556
|
-
ARN?: string
|
|
557
|
-
Name?: string
|
|
558
|
-
}> {
|
|
559
|
-
const params: Record<string, any> = {
|
|
560
|
-
SecretId: options.SecretId,
|
|
561
|
-
ResourcePolicy: options.ResourcePolicy,
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (options.BlockPublicPolicy !== undefined) {
|
|
565
|
-
params.BlockPublicPolicy = options.BlockPublicPolicy
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
const result = await this.client.request({
|
|
569
|
-
service: 'secretsmanager',
|
|
570
|
-
region: this.region,
|
|
571
|
-
method: 'POST',
|
|
572
|
-
path: '/',
|
|
573
|
-
headers: {
|
|
574
|
-
'X-Amz-Target': 'secretsmanager.PutResourcePolicy',
|
|
575
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
576
|
-
},
|
|
577
|
-
body: JSON.stringify(params),
|
|
578
|
-
})
|
|
579
|
-
|
|
580
|
-
return {
|
|
581
|
-
ARN: result.ARN,
|
|
582
|
-
Name: result.Name,
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Delete resource policy for a secret
|
|
588
|
-
*/
|
|
589
|
-
async deleteResourcePolicy(secretId: string): Promise<{
|
|
590
|
-
ARN?: string
|
|
591
|
-
Name?: string
|
|
592
|
-
}> {
|
|
593
|
-
const params: Record<string, any> = {
|
|
594
|
-
SecretId: secretId,
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
const result = await this.client.request({
|
|
598
|
-
service: 'secretsmanager',
|
|
599
|
-
region: this.region,
|
|
600
|
-
method: 'POST',
|
|
601
|
-
path: '/',
|
|
602
|
-
headers: {
|
|
603
|
-
'X-Amz-Target': 'secretsmanager.DeleteResourcePolicy',
|
|
604
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
605
|
-
},
|
|
606
|
-
body: JSON.stringify(params),
|
|
607
|
-
})
|
|
608
|
-
|
|
609
|
-
return {
|
|
610
|
-
ARN: result.ARN,
|
|
611
|
-
Name: result.Name,
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Tag a secret
|
|
617
|
-
*/
|
|
618
|
-
async tagResource(options: {
|
|
619
|
-
SecretId: string
|
|
620
|
-
Tags: { Key: string, Value: string }[]
|
|
621
|
-
}): Promise<void> {
|
|
622
|
-
const params: Record<string, any> = {
|
|
623
|
-
SecretId: options.SecretId,
|
|
624
|
-
Tags: options.Tags,
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
await this.client.request({
|
|
628
|
-
service: 'secretsmanager',
|
|
629
|
-
region: this.region,
|
|
630
|
-
method: 'POST',
|
|
631
|
-
path: '/',
|
|
632
|
-
headers: {
|
|
633
|
-
'X-Amz-Target': 'secretsmanager.TagResource',
|
|
634
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
635
|
-
},
|
|
636
|
-
body: JSON.stringify(params),
|
|
637
|
-
})
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Remove tags from a secret
|
|
642
|
-
*/
|
|
643
|
-
async untagResource(options: {
|
|
644
|
-
SecretId: string
|
|
645
|
-
TagKeys: string[]
|
|
646
|
-
}): Promise<void> {
|
|
647
|
-
const params: Record<string, any> = {
|
|
648
|
-
SecretId: options.SecretId,
|
|
649
|
-
TagKeys: options.TagKeys,
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
await this.client.request({
|
|
653
|
-
service: 'secretsmanager',
|
|
654
|
-
region: this.region,
|
|
655
|
-
method: 'POST',
|
|
656
|
-
path: '/',
|
|
657
|
-
headers: {
|
|
658
|
-
'X-Amz-Target': 'secretsmanager.UntagResource',
|
|
659
|
-
'Content-Type': 'application/x-amz-json-1.1',
|
|
660
|
-
},
|
|
661
|
-
body: JSON.stringify(params),
|
|
662
|
-
})
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Helper: Set a string secret
|
|
667
|
-
*/
|
|
668
|
-
async setString(name: string, value: string, options?: {
|
|
669
|
-
description?: string
|
|
670
|
-
kmsKeyId?: string
|
|
671
|
-
tags?: { Key: string, Value: string }[]
|
|
672
|
-
}): Promise<{ ARN?: string, VersionId?: string }> {
|
|
673
|
-
// Try to update existing, create if doesn't exist
|
|
674
|
-
try {
|
|
675
|
-
const result = await this.putSecretValue({
|
|
676
|
-
SecretId: name,
|
|
677
|
-
SecretString: value,
|
|
678
|
-
})
|
|
679
|
-
return { ARN: result.ARN, VersionId: result.VersionId }
|
|
680
|
-
}
|
|
681
|
-
catch (error: any) {
|
|
682
|
-
if (error.code === 'ResourceNotFoundException') {
|
|
683
|
-
const result = await this.createSecret({
|
|
684
|
-
Name: name,
|
|
685
|
-
SecretString: value,
|
|
686
|
-
Description: options?.description,
|
|
687
|
-
KmsKeyId: options?.kmsKeyId,
|
|
688
|
-
Tags: options?.tags,
|
|
689
|
-
})
|
|
690
|
-
return { ARN: result.ARN, VersionId: result.VersionId }
|
|
691
|
-
}
|
|
692
|
-
throw error
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Helper: Set a JSON secret
|
|
698
|
-
*/
|
|
699
|
-
async setJson(name: string, value: Record<string, any>, options?: {
|
|
700
|
-
description?: string
|
|
701
|
-
kmsKeyId?: string
|
|
702
|
-
tags?: { Key: string, Value: string }[]
|
|
703
|
-
}): Promise<{ ARN?: string, VersionId?: string }> {
|
|
704
|
-
return this.setString(name, JSON.stringify(value), options)
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Helper: Get a string secret value
|
|
709
|
-
*/
|
|
710
|
-
async getString(secretId: string): Promise<string | undefined> {
|
|
711
|
-
const result = await this.getSecretValue({ SecretId: secretId })
|
|
712
|
-
return result.SecretString
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Helper: Get a JSON secret value
|
|
717
|
-
*/
|
|
718
|
-
async getJson<T = Record<string, any>>(secretId: string): Promise<T | undefined> {
|
|
719
|
-
const str = await this.getString(secretId)
|
|
720
|
-
if (str) {
|
|
721
|
-
return JSON.parse(str) as T
|
|
722
|
-
}
|
|
723
|
-
return undefined
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Helper: List all secrets
|
|
728
|
-
*/
|
|
729
|
-
async listAll(): Promise<Secret[]> {
|
|
730
|
-
const allSecrets: Secret[] = []
|
|
731
|
-
let nextToken: string | undefined
|
|
732
|
-
|
|
733
|
-
do {
|
|
734
|
-
const result = await this.listSecrets({ NextToken: nextToken })
|
|
735
|
-
|
|
736
|
-
if (result.SecretList) {
|
|
737
|
-
allSecrets.push(...result.SecretList)
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
nextToken = result.NextToken
|
|
741
|
-
} while (nextToken)
|
|
742
|
-
|
|
743
|
-
return allSecrets
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Parse secret response
|
|
748
|
-
*/
|
|
749
|
-
private parseSecret(s: any): Secret {
|
|
750
|
-
return {
|
|
751
|
-
ARN: s.ARN,
|
|
752
|
-
Name: s.Name,
|
|
753
|
-
Description: s.Description,
|
|
754
|
-
KmsKeyId: s.KmsKeyId,
|
|
755
|
-
RotationEnabled: s.RotationEnabled,
|
|
756
|
-
RotationLambdaARN: s.RotationLambdaARN,
|
|
757
|
-
RotationRules: s.RotationRules,
|
|
758
|
-
LastRotatedDate: s.LastRotatedDate,
|
|
759
|
-
LastChangedDate: s.LastChangedDate,
|
|
760
|
-
LastAccessedDate: s.LastAccessedDate,
|
|
761
|
-
DeletedDate: s.DeletedDate,
|
|
762
|
-
NextRotationDate: s.NextRotationDate,
|
|
763
|
-
Tags: s.Tags,
|
|
764
|
-
SecretVersionsToStages: s.SecretVersionsToStages,
|
|
765
|
-
CreatedDate: s.CreatedDate,
|
|
766
|
-
PrimaryRegion: s.PrimaryRegion,
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|