@webda/aws 4.0.0-beta.3 → 4.0.0-beta.4

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.
Files changed (36) hide show
  1. package/lib/deployers/awsdeployer.d.ts +340 -0
  2. package/lib/deployers/awsdeployer.d.ts.map +1 -0
  3. package/lib/deployers/awsdeployer.js +673 -0
  4. package/lib/deployers/awsdeployer.js.map +1 -0
  5. package/lib/deployers/cloudformation.service.d.ts +438 -0
  6. package/lib/deployers/cloudformation.service.d.ts.map +1 -0
  7. package/lib/deployers/cloudformation.service.js +889 -0
  8. package/lib/deployers/cloudformation.service.js.map +1 -0
  9. package/lib/deployers/index.d.ts +5 -0
  10. package/lib/deployers/index.d.ts.map +1 -0
  11. package/lib/deployers/index.js +5 -0
  12. package/lib/deployers/index.js.map +1 -0
  13. package/lib/deployers/lambda-entrypoint.d.ts +34 -0
  14. package/lib/deployers/lambda-entrypoint.d.ts.map +1 -0
  15. package/lib/deployers/lambda-entrypoint.js +47 -0
  16. package/lib/deployers/lambda-entrypoint.js.map +1 -0
  17. package/lib/deployers/lambdapackager.service.d.ts +123 -0
  18. package/lib/deployers/lambdapackager.service.d.ts.map +1 -0
  19. package/lib/deployers/lambdapackager.service.js +149 -0
  20. package/lib/deployers/lambdapackager.service.js.map +1 -0
  21. package/lib/deployers/zip.d.ts +42 -0
  22. package/lib/deployers/zip.d.ts.map +1 -0
  23. package/lib/deployers/zip.js +129 -0
  24. package/lib/deployers/zip.js.map +1 -0
  25. package/lib/index.d.ts +1 -0
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +1 -0
  28. package/lib/index.js.map +1 -1
  29. package/lib/services/contributors.d.ts +1 -2
  30. package/lib/services/contributors.d.ts.map +1 -1
  31. package/lib/services/dynamodb.service.d.ts +2 -1
  32. package/lib/services/dynamodb.service.d.ts.map +1 -1
  33. package/lib/services/dynamodb.service.js +5 -4
  34. package/lib/services/dynamodb.service.js.map +1 -1
  35. package/package.json +8 -11
  36. package/webda.module.json +698 -0
@@ -0,0 +1,340 @@
1
+ import { CertificateDetail } from "@aws-sdk/client-acm";
2
+ import { HostedZone, RRType } from "@aws-sdk/client-route-53";
3
+ import { S3 } from "@aws-sdk/client-s3";
4
+ import { GetCallerIdentityResponse } from "@aws-sdk/client-sts";
5
+ import { Service, ServiceParameters } from "@webda/core";
6
+ /**
7
+ * Tags as an AWS array or as a map
8
+ */
9
+ export type TagsDefinition = {
10
+ Key: string;
11
+ Value: string;
12
+ }[] | {
13
+ [key: string]: string;
14
+ };
15
+ /**
16
+ * AWS clients a deployer can target with a custom endpoint
17
+ */
18
+ export type AWSDeployerEndpoint = "ACM" | "S3" | "STS" | "EC2" | "Route53" | "CloudFormation" | "APIGateway" | "CloudFront";
19
+ /**
20
+ * Common parameters of the AWS deployers
21
+ *
22
+ * A deployer is declared as a unit of a deployment (`deployments/<name>.json`),
23
+ * its parameters can use the `${...}` deployment variables ({@link getDeploymentVariables})
24
+ */
25
+ export declare class AWSDeployerParameters extends ServiceParameters {
26
+ /**
27
+ * Name of the unit
28
+ */
29
+ name?: string;
30
+ /**
31
+ * AWS_ACCESS_KEY_ID to use
32
+ *
33
+ * Using static key is not recommended
34
+ */
35
+ accessKeyId?: string;
36
+ /**
37
+ * AWS_SECRET_ACCESS_KEY to use
38
+ *
39
+ * Using static key is not recommended
40
+ */
41
+ secretAccessKey?: string;
42
+ /**
43
+ * AWS_SESSION_TOKEN Token
44
+ *
45
+ * Even if it is possible to add it here
46
+ * It is not sustainable as this token at its best will
47
+ * have a lifetime of 12 hours
48
+ */
49
+ sessionToken?: string;
50
+ /**
51
+ * AWS_REGION to use
52
+ *
53
+ * @default "us-east-1"
54
+ */
55
+ region?: string;
56
+ /**
57
+ * AWS Account Id
58
+ */
59
+ AWSAccountId?: string;
60
+ /**
61
+ * Endpoints to use by differents services
62
+ * Usefull to test with localstack or other AWS emulations
63
+ */
64
+ endpoints?: {
65
+ [key in AWSDeployerEndpoint]?: string;
66
+ };
67
+ /**
68
+ * Default Tags to use with resources created by deployers
69
+ */
70
+ Tags?: TagsDefinition;
71
+ /**
72
+ * SSL certificates to create
73
+ *
74
+ * Sample
75
+ * ```
76
+ * Certificates: {
77
+ * "test.webda.io": {
78
+ * SubjectAlternativeNames: ["test2.webda.io"]
79
+ * }
80
+ * }
81
+ * ```
82
+ */
83
+ Certificates?: {
84
+ [key: string]: {
85
+ /**
86
+ * Any alternative names to add to the certificate
87
+ */
88
+ SubjectAlternativeNames?: string[];
89
+ Tags?: TagsDefinition;
90
+ [key: string]: any;
91
+ };
92
+ };
93
+ }
94
+ /**
95
+ * Plain resources of a deployer: its parameters with the deployment variables replaced
96
+ */
97
+ export type DeployerResources<T> = Omit<T, "load" | "update" | "with" | "watch">;
98
+ /**
99
+ * Abstract AWS Deployer
100
+ *
101
+ * It includes some basic utilities methods to be used by
102
+ * final deployers. A final deployer declares `implements Deployer` itself.
103
+ */
104
+ export declare abstract class AWSDeployer<T extends AWSDeployerParameters = AWSDeployerParameters> extends Service<T> {
105
+ /**
106
+ * Parameters of the deployer with the deployment variables replaced and the defaults applied
107
+ *
108
+ * Computed by {@link AWSDeployer.prepare}
109
+ */
110
+ resources: DeployerResources<T> & {
111
+ [key: string]: any;
112
+ };
113
+ /**
114
+ * Compute the resources from the parameters
115
+ *
116
+ * @param extra - additional deployment variables
117
+ * @returns the resources
118
+ */
119
+ prepare(extra?: Record<string, any>): Promise<this["resources"]>;
120
+ /**
121
+ * Parameters as a plain object
122
+ * @returns a copy of the parameters
123
+ */
124
+ protected getRawParameters(): any;
125
+ /**
126
+ * Apply the default resources
127
+ */
128
+ defaultResources(): Promise<void>;
129
+ /**
130
+ * Configuration of an AWS client
131
+ *
132
+ * @param endpoint - the client, to use its custom endpoint
133
+ * @param region - force a region
134
+ * @returns the client configuration
135
+ */
136
+ getClientConfig(endpoint?: AWSDeployerEndpoint, region?: string): any;
137
+ /**
138
+ * Return AWS region
139
+ * @returns the region
140
+ */
141
+ getRegion(): string;
142
+ /**
143
+ * Return the current AWS Identity used
144
+ * @returns the identity
145
+ */
146
+ getAWSIdentity(): Promise<GetCallerIdentityResponse>;
147
+ /**
148
+ * Return the default VPC for the current region
149
+ * @returns the VPC id and its subnets, undefined if there is no default VPC
150
+ */
151
+ getDefaultVpc(): Promise<{
152
+ Id: string;
153
+ Subnets: any[];
154
+ } | undefined>;
155
+ /**
156
+ * Generate a MD5 in hex
157
+ * @param str - to hash
158
+ * @returns the hash
159
+ */
160
+ protected md5(str: string): string;
161
+ /**
162
+ * Hash the string
163
+ *
164
+ * @param str - to hash
165
+ * @param type - of hash
166
+ * @param format - hex or b64
167
+ * @returns the hash
168
+ */
169
+ protected hash(str: string | Buffer, type?: string, format?: "hex" | "base64"): string;
170
+ /**
171
+ * Replace / by _ as theses ID are not allowed in AWS
172
+ *
173
+ * @param id - to replace
174
+ * @returns the AWS compatible id
175
+ */
176
+ _replaceForAWS(id: string): string;
177
+ /**
178
+ * Get a certificate or create it
179
+ *
180
+ * @param domain - to get certificate for
181
+ * @param region - of the certificate
182
+ * @returns the certificate
183
+ */
184
+ getCertificate(domain: string, region?: string): Promise<any>;
185
+ /**
186
+ * Get the closest zone to the domain
187
+ *
188
+ * @param domain - to get zone for
189
+ * @returns the zone
190
+ */
191
+ getZoneForDomainName(domain: string): Promise<HostedZone>;
192
+ /**
193
+ * Transform a tag map into a tag array
194
+ *
195
+ * @param tags - to transform
196
+ * @returns the tags array
197
+ */
198
+ transformMapTagsToArray(tags: TagsDefinition): {
199
+ Key: string;
200
+ Value: string;
201
+ }[];
202
+ /**
203
+ * Transform a tag array into a tag map
204
+ *
205
+ * @param tags - to transform
206
+ * @returns the tags map
207
+ */
208
+ transformArrayTagsToMap(tags: TagsDefinition): {
209
+ [key: string]: string;
210
+ };
211
+ /**
212
+ * Take this.resources[key].Tags and add all remaining Tags from this.resources.Tags
213
+ *
214
+ * @param key - of the resources to add, or the tags themselves
215
+ * @returns the tags array
216
+ */
217
+ getDefaultTags(key?: string | TagsDefinition): {
218
+ Key: string;
219
+ Value: string;
220
+ }[];
221
+ /**
222
+ * Take this.resources[key].Tags and add all remaining Tags from this.resources.Tags
223
+ *
224
+ * @param key - of the resources to add
225
+ * @returns the tags map
226
+ */
227
+ getDefaultTagsAsMap(key?: string | TagsDefinition): {
228
+ [key: string]: string;
229
+ };
230
+ /**
231
+ * Return the S3 Tagging string
232
+ * @param key - of the resources to add
233
+ * @returns the url encoded tags
234
+ */
235
+ getDefaultTagsAsS3Tagging(key?: string | TagsDefinition): string;
236
+ /**
237
+ * Wait for a condition with a linear delay
238
+ *
239
+ * @param callback - resolve when done, return true to stop
240
+ * @param retries - maximum number of tries
241
+ * @param title - of the wait
242
+ * @param delay - between tries in ms
243
+ * @returns the resolved value
244
+ */
245
+ waitFor(callback: (resolve?: (value?: any) => void, reject?: (reason?: any) => void) => Promise<boolean>, retries: number, title: string, delay: number): Promise<any>;
246
+ /**
247
+ * Create a certificate for a domain
248
+ * Will use Route 53 to do the validation
249
+ *
250
+ * @param domain - to create the certificate for
251
+ * @param zone - to create the validation record in
252
+ * @param region - of the certificate
253
+ * @returns the certificate
254
+ */
255
+ doCreateCertificate(domain: string, zone: HostedZone, region?: string): Promise<CertificateDetail>;
256
+ /**
257
+ * Create DNS entry
258
+ *
259
+ * @param domain - to create
260
+ * @param type - of DNS
261
+ * @param value - the value of the record
262
+ * @param targetZone - the zone, found from the domain if not provided
263
+ */
264
+ createDNSEntry(domain: string, type: RRType, value: string, targetZone?: HostedZone): Promise<void>;
265
+ /**
266
+ * Permissions needed by the deployed application itself
267
+ *
268
+ * @param accountId - the account
269
+ * @param region - the region
270
+ * @returns the policy statements
271
+ */
272
+ getARNPolicy(accountId: string, region: string): any[];
273
+ /**
274
+ * Generate the `PolicyDocument`
275
+ *
276
+ * It will browse all services for a method `getARNPolicy`
277
+ * Allowing you to write some specific Service or Bean that
278
+ * requires specific AWS permissions
279
+ *
280
+ * @param additionalStatements - statements to add
281
+ * @returns the optimized policy document
282
+ */
283
+ getPolicyDocument(additionalStatements?: any[]): Promise<any>;
284
+ /**
285
+ * Services of the application, the deployers excluded
286
+ *
287
+ * @returns the services
288
+ */
289
+ getApplicationServices(): Service[];
290
+ /**
291
+ * Create a bucket if it does not exist
292
+ *
293
+ * @param Bucket - to create
294
+ */
295
+ createBucket(Bucket: string): Promise<void>;
296
+ /**
297
+ * S3 client
298
+ * @returns the client
299
+ */
300
+ protected getS3(): S3;
301
+ /**
302
+ * Send a full folder (recursive) on bucket
303
+ *
304
+ * @param bucket - to send data to
305
+ * @param folder - path to local folder to send
306
+ * @param prefix - prefix on the bucket
307
+ */
308
+ putFolderOnBucket(bucket: string, folder: string, prefix?: string): Promise<void>;
309
+ /**
310
+ * Find the common prefix between two strings
311
+ *
312
+ * Example
313
+ * ```
314
+ * commonPrefix("/test/plop1", "/templates/") => "/te"
315
+ * ```
316
+ *
317
+ * @param str1 - to compare
318
+ * @param str2 - to compare
319
+ * @returns the common prefix
320
+ */
321
+ commonPrefix(str1: string, str2: string): string;
322
+ /**
323
+ * Add files to a bucket
324
+ *
325
+ * It uses hash and ETag to avoid uploading files already present
326
+ *
327
+ * The files src can be either:
328
+ * - a string representing the local path
329
+ * - a Buffer with the dynamic content
330
+ *
331
+ * @param bucket - to send bucket
332
+ * @param files - to send
333
+ */
334
+ putFilesOnBucket(bucket: string, files: {
335
+ key?: string;
336
+ src: any;
337
+ mimetype?: string;
338
+ }[]): Promise<void>;
339
+ }
340
+ //# sourceMappingURL=awsdeployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awsdeployer.d.ts","sourceRoot":"","sources":["../../src/deployers/awsdeployer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,iBAAiB,EAA4D,MAAM,qBAAqB,CAAC;AAEvH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAW,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAY,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yB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