@stacksjs/ts-cloud 0.5.6 → 0.5.8
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/dist/aws/cloudwatch.d.ts +63 -0
- package/dist/aws/lambda.d.ts +22 -0
- package/dist/aws/rds.d.ts +29 -0
- package/dist/bin/cli.js +687 -718
- package/dist/deploy/serverless-app.d.ts +46 -0
- package/dist/index.js +1991 -1870
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -26187,34 +26187,39 @@ function composeServerlessAppTemplate(opts) {
|
|
|
26187
26187
|
}
|
|
26188
26188
|
if (app.warm && app.warm > 0) {
|
|
26189
26189
|
const TARGETS_PER_RULE = 5;
|
|
26190
|
-
const
|
|
26191
|
-
|
|
26192
|
-
for (
|
|
26193
|
-
const
|
|
26194
|
-
|
|
26195
|
-
|
|
26190
|
+
const fnResource = { http: "HttpFunction", queue: "QueueFunction", cli: "CliFunction" };
|
|
26191
|
+
const warmModes = (app.warmFunctions ?? ["http"]).filter((m) => m !== "queue" || hasQueue);
|
|
26192
|
+
for (const mode of warmModes) {
|
|
26193
|
+
const cap = mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
26194
|
+
const ruleCount = Math.ceil(app.warm / TARGETS_PER_RULE);
|
|
26195
|
+
let warmed = 0;
|
|
26196
|
+
for (let r = 0;r < ruleCount; r++) {
|
|
26197
|
+
const targets = Math.min(TARGETS_PER_RULE, app.warm - warmed);
|
|
26198
|
+
resources[`Warmer${cap}Rule${r}`] = {
|
|
26199
|
+
Type: "AWS::Events::Rule",
|
|
26200
|
+
Properties: {
|
|
26201
|
+
Name: `${slug}-${environment}-warmer-${mode}-${r}`,
|
|
26202
|
+
ScheduleExpression: "rate(5 minutes)",
|
|
26203
|
+
State: "ENABLED",
|
|
26204
|
+
Targets: Array.from({ length: targets }, (_, i) => ({
|
|
26205
|
+
Id: `warm-${mode}-${r}-${i}`,
|
|
26206
|
+
Arn: Fn2.getAtt(fnResource[mode], "Arn"),
|
|
26207
|
+
Input: JSON.stringify({ warmer: true })
|
|
26208
|
+
}))
|
|
26209
|
+
}
|
|
26210
|
+
};
|
|
26211
|
+
warmed += targets;
|
|
26212
|
+
}
|
|
26213
|
+
resources[`Warmer${cap}Permission`] = {
|
|
26214
|
+
Type: "AWS::Lambda::Permission",
|
|
26196
26215
|
Properties: {
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
|
|
26201
|
-
Id: `warm-${r}-${i}`,
|
|
26202
|
-
Arn: Fn2.getAtt("HttpFunction", "Arn"),
|
|
26203
|
-
Input: JSON.stringify({ warmer: true })
|
|
26204
|
-
}))
|
|
26216
|
+
FunctionName: Fn2.ref(fnResource[mode]),
|
|
26217
|
+
Action: "lambda:InvokeFunction",
|
|
26218
|
+
Principal: "events.amazonaws.com",
|
|
26219
|
+
SourceArn: Fn2.sub(`arn:aws:events:\${AWS::Region}:\${AWS::AccountId}:rule/${slug}-${environment}-warmer-${mode}-*`)
|
|
26205
26220
|
}
|
|
26206
26221
|
};
|
|
26207
|
-
warmed += targets;
|
|
26208
26222
|
}
|
|
26209
|
-
resources.WarmerPermission = {
|
|
26210
|
-
Type: "AWS::Lambda::Permission",
|
|
26211
|
-
Properties: {
|
|
26212
|
-
FunctionName: Fn2.ref("HttpFunction"),
|
|
26213
|
-
Action: "lambda:InvokeFunction",
|
|
26214
|
-
Principal: "events.amazonaws.com",
|
|
26215
|
-
SourceArn: Fn2.sub(`arn:aws:events:\${AWS::Region}:\${AWS::AccountId}:rule/${slug}-${environment}-warmer-*`)
|
|
26216
|
-
}
|
|
26217
|
-
};
|
|
26218
26223
|
}
|
|
26219
26224
|
if (cacheEnabled) {
|
|
26220
26225
|
resources.CacheTable = {
|
|
@@ -26471,7 +26476,10 @@ function composeServerlessAppTemplate(opts) {
|
|
|
26471
26476
|
DatabaseName: "app",
|
|
26472
26477
|
MasterUsername: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:username}}"),
|
|
26473
26478
|
MasterUserPassword: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:password}}"),
|
|
26474
|
-
ServerlessV2ScalingConfiguration: {
|
|
26479
|
+
ServerlessV2ScalingConfiguration: {
|
|
26480
|
+
MinCapacity: app.database?.minCapacity ?? 0.5,
|
|
26481
|
+
MaxCapacity: app.database?.maxCapacity ?? 4
|
|
26482
|
+
},
|
|
26475
26483
|
DBSubnetGroupName: Fn2.ref("DbSubnetGroup"),
|
|
26476
26484
|
VpcSecurityGroupIds: [Fn2.getAtt("DataSecurityGroup", "GroupId")]
|
|
26477
26485
|
}
|
|
@@ -26804,6 +26812,8 @@ function parseRecordBody(body) {
|
|
|
26804
26812
|
function createQueueHandler(handler8) {
|
|
26805
26813
|
return async (event) => {
|
|
26806
26814
|
const batchItemFailures = [];
|
|
26815
|
+
if (event.warmer)
|
|
26816
|
+
return { batchItemFailures };
|
|
26807
26817
|
if (!handler8)
|
|
26808
26818
|
return { batchItemFailures };
|
|
26809
26819
|
for (const record of event.Records ?? []) {
|
|
@@ -26818,6 +26828,8 @@ function createQueueHandler(handler8) {
|
|
|
26818
26828
|
}
|
|
26819
26829
|
function createCliHandler(handler8) {
|
|
26820
26830
|
return async (event) => {
|
|
26831
|
+
if (event.warmer)
|
|
26832
|
+
return { statusCode: 0, output: "warm" };
|
|
26821
26833
|
if (!handler8)
|
|
26822
26834
|
return { statusCode: 501, output: "No CLI handler configured" };
|
|
26823
26835
|
return handler8(event);
|
|
@@ -55715,396 +55727,992 @@ var init_email = __esm(() => {
|
|
|
55715
55727
|
email = new EmailClient;
|
|
55716
55728
|
});
|
|
55717
55729
|
|
|
55718
|
-
// src/
|
|
55719
|
-
|
|
55720
|
-
|
|
55721
|
-
|
|
55722
|
-
|
|
55723
|
-
|
|
55724
|
-
|
|
55725
|
-
|
|
55726
|
-
|
|
55727
|
-
|
|
55728
|
-
|
|
55729
|
-
|
|
55730
|
-
|
|
55731
|
-
|
|
55732
|
-
|
|
55733
|
-
retainOnStackDelete = false
|
|
55734
|
-
} = config6;
|
|
55735
|
-
const retainPolicy = retainOnStackDelete ? { DeletionPolicy: "Retain", UpdateReplacePolicy: "Retain" } : {};
|
|
55736
|
-
const useComputeOrigin = dynamicApp && !!computeOriginDomain;
|
|
55737
|
-
const defaultAllowedMethods = useComputeOrigin ? ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] : ["GET", "HEAD"];
|
|
55738
|
-
const defaultCachedMethods = useComputeOrigin ? ["GET", "HEAD"] : ["GET", "HEAD"];
|
|
55739
|
-
const resources = {};
|
|
55740
|
-
const outputs = {};
|
|
55741
|
-
resources.S3Bucket = {
|
|
55742
|
-
Type: "AWS::S3::Bucket",
|
|
55743
|
-
...retainPolicy,
|
|
55744
|
-
Properties: {
|
|
55745
|
-
BucketName: bucketName,
|
|
55746
|
-
PublicAccessBlockConfiguration: {
|
|
55747
|
-
BlockPublicAcls: true,
|
|
55748
|
-
BlockPublicPolicy: false,
|
|
55749
|
-
IgnorePublicAcls: true,
|
|
55750
|
-
RestrictPublicBuckets: false
|
|
55751
|
-
},
|
|
55752
|
-
WebsiteConfiguration: {
|
|
55753
|
-
IndexDocument: defaultRootObject,
|
|
55754
|
-
ErrorDocument: errorDocument
|
|
55755
|
-
}
|
|
55730
|
+
// src/aws/rds.ts
|
|
55731
|
+
class RDSClient {
|
|
55732
|
+
client;
|
|
55733
|
+
region;
|
|
55734
|
+
constructor(region = "us-east-1") {
|
|
55735
|
+
this.region = region;
|
|
55736
|
+
this.client = new AWSClient;
|
|
55737
|
+
}
|
|
55738
|
+
async describeDBInstances(options) {
|
|
55739
|
+
const params = {
|
|
55740
|
+
Action: "DescribeDBInstances",
|
|
55741
|
+
Version: "2014-10-31"
|
|
55742
|
+
};
|
|
55743
|
+
if (options?.DBInstanceIdentifier) {
|
|
55744
|
+
params.DBInstanceIdentifier = options.DBInstanceIdentifier;
|
|
55756
55745
|
}
|
|
55757
|
-
|
|
55758
|
-
|
|
55759
|
-
Description: "S3 Bucket Name",
|
|
55760
|
-
Value: { Ref: "S3Bucket" }
|
|
55761
|
-
};
|
|
55762
|
-
outputs.BucketArn = {
|
|
55763
|
-
Description: "S3 Bucket ARN",
|
|
55764
|
-
Value: { "Fn::GetAtt": ["S3Bucket", "Arn"] }
|
|
55765
|
-
};
|
|
55766
|
-
resources.CloudFrontOAC = {
|
|
55767
|
-
Type: "AWS::CloudFront::OriginAccessControl",
|
|
55768
|
-
...retainPolicy,
|
|
55769
|
-
Properties: {
|
|
55770
|
-
OriginAccessControlConfig: {
|
|
55771
|
-
Name: `OAC-${bucketName}`,
|
|
55772
|
-
Description: `OAC for ${bucketName}`,
|
|
55773
|
-
OriginAccessControlOriginType: "s3",
|
|
55774
|
-
SigningBehavior: "always",
|
|
55775
|
-
SigningProtocol: "sigv4"
|
|
55776
|
-
}
|
|
55746
|
+
if (options?.MaxRecords) {
|
|
55747
|
+
params.MaxRecords = options.MaxRecords;
|
|
55777
55748
|
}
|
|
55778
|
-
|
|
55779
|
-
|
|
55780
|
-
|
|
55781
|
-
|
|
55782
|
-
|
|
55783
|
-
|
|
55784
|
-
|
|
55785
|
-
|
|
55786
|
-
|
|
55787
|
-
|
|
55788
|
-
|
|
55789
|
-
|
|
55790
|
-
|
|
55791
|
-
|
|
55792
|
-
|
|
55793
|
-
|
|
55794
|
-
|
|
55795
|
-
statusCode: 302,
|
|
55796
|
-
statusDescription: 'Found',
|
|
55749
|
+
if (options?.Marker) {
|
|
55750
|
+
params.Marker = options.Marker;
|
|
55751
|
+
}
|
|
55752
|
+
if (options?.Filters) {
|
|
55753
|
+
options.Filters.forEach((filter, i) => {
|
|
55754
|
+
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
55755
|
+
filter.Values.forEach((value, j) => {
|
|
55756
|
+
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
55757
|
+
});
|
|
55758
|
+
});
|
|
55759
|
+
}
|
|
55760
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55761
|
+
const result = await this.client.request({
|
|
55762
|
+
service: "rds",
|
|
55763
|
+
region: this.region,
|
|
55764
|
+
method: "POST",
|
|
55765
|
+
path: "/",
|
|
55797
55766
|
headers: {
|
|
55798
|
-
|
|
55799
|
-
}
|
|
55800
|
-
|
|
55801
|
-
|
|
55802
|
-
|
|
55803
|
-
|
|
55804
|
-
|
|
55767
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55768
|
+
},
|
|
55769
|
+
body: queryString
|
|
55770
|
+
});
|
|
55771
|
+
const response = result.DescribeDBInstancesResult || result;
|
|
55772
|
+
let instances = response.DBInstances?.DBInstance || [];
|
|
55773
|
+
if (!Array.isArray(instances)) {
|
|
55774
|
+
instances = instances ? [instances] : [];
|
|
55775
|
+
}
|
|
55776
|
+
return {
|
|
55777
|
+
DBInstances: instances,
|
|
55778
|
+
Marker: response.Marker
|
|
55805
55779
|
};
|
|
55806
55780
|
}
|
|
55807
|
-
|
|
55808
|
-
|
|
55809
|
-
|
|
55810
|
-
Properties: {
|
|
55811
|
-
Name: { "Fn::Sub": "${AWS::StackName}-url-rewrite" },
|
|
55812
|
-
AutoPublish: true,
|
|
55813
|
-
FunctionConfig: {
|
|
55814
|
-
Comment: "Append .html extension to URLs without extensions",
|
|
55815
|
-
Runtime: "cloudfront-js-2.0"
|
|
55816
|
-
},
|
|
55817
|
-
FunctionCode: `function handler(event) {
|
|
55818
|
-
const request = event.request;
|
|
55819
|
-
var uri = request.uri;
|
|
55820
|
-
|
|
55821
|
-
// If URI ends with /, serve index.html
|
|
55822
|
-
if (uri.endsWith('/')) {
|
|
55823
|
-
request.uri = uri + 'index.html';
|
|
55824
|
-
}
|
|
55825
|
-
// If URI doesn't have an extension, append .html
|
|
55826
|
-
else if (!uri.includes('.')) {
|
|
55827
|
-
request.uri = uri + '.html';
|
|
55781
|
+
async describeDBInstance(dbInstanceIdentifier) {
|
|
55782
|
+
const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
|
|
55783
|
+
return result.DBInstances?.[0];
|
|
55828
55784
|
}
|
|
55829
|
-
|
|
55830
|
-
|
|
55831
|
-
|
|
55832
|
-
|
|
55785
|
+
async describeDBClusters(options) {
|
|
55786
|
+
const params = {
|
|
55787
|
+
Action: "DescribeDBClusters",
|
|
55788
|
+
Version: "2014-10-31"
|
|
55833
55789
|
};
|
|
55834
|
-
|
|
55835
|
-
|
|
55836
|
-
Id: `S3-${bucketName}`,
|
|
55837
|
-
DomainName: { "Fn::GetAtt": ["S3Bucket", "RegionalDomainName"] },
|
|
55838
|
-
S3OriginConfig: {
|
|
55839
|
-
OriginAccessIdentity: ""
|
|
55840
|
-
},
|
|
55841
|
-
OriginAccessControlId: { "Fn::GetAtt": ["CloudFrontOAC", "Id"] }
|
|
55842
|
-
};
|
|
55843
|
-
const computeOrigin = useComputeOrigin ? {
|
|
55844
|
-
Id: computeOriginId,
|
|
55845
|
-
DomainName: computeOriginDomain,
|
|
55846
|
-
CustomOriginConfig: {
|
|
55847
|
-
HTTPPort: computeOriginPort,
|
|
55848
|
-
HTTPSPort: 443,
|
|
55849
|
-
OriginProtocolPolicy: "http-only",
|
|
55850
|
-
OriginSSLProtocols: ["TLSv1.2"]
|
|
55790
|
+
if (options?.DBClusterIdentifier) {
|
|
55791
|
+
params.DBClusterIdentifier = options.DBClusterIdentifier;
|
|
55851
55792
|
}
|
|
55852
|
-
|
|
55853
|
-
|
|
55854
|
-
|
|
55855
|
-
|
|
55856
|
-
|
|
55857
|
-
|
|
55858
|
-
|
|
55859
|
-
|
|
55860
|
-
|
|
55861
|
-
|
|
55862
|
-
|
|
55863
|
-
|
|
55864
|
-
|
|
55865
|
-
|
|
55866
|
-
|
|
55867
|
-
|
|
55868
|
-
|
|
55869
|
-
|
|
55870
|
-
|
|
55871
|
-
|
|
55872
|
-
|
|
55873
|
-
|
|
55874
|
-
}]
|
|
55875
|
-
} : {}
|
|
55876
|
-
} : {
|
|
55877
|
-
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6",
|
|
55878
|
-
...!passthroughUrls && {
|
|
55879
|
-
FunctionAssociations: [
|
|
55880
|
-
{
|
|
55881
|
-
EventType: "viewer-request",
|
|
55882
|
-
FunctionARN: { "Fn::GetAtt": ["UrlRewriteFunction", "FunctionARN"] }
|
|
55883
|
-
}
|
|
55884
|
-
]
|
|
55885
|
-
}
|
|
55886
|
-
}
|
|
55887
|
-
},
|
|
55888
|
-
...useComputeOrigin && passthroughUrls ? {
|
|
55889
|
-
CacheBehaviors: [
|
|
55890
|
-
{
|
|
55891
|
-
PathPattern: "/install.sh",
|
|
55892
|
-
TargetOriginId: `S3-${bucketName}`,
|
|
55893
|
-
ViewerProtocolPolicy: "redirect-to-https",
|
|
55894
|
-
AllowedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
55895
|
-
CachedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
55896
|
-
Compress: true,
|
|
55897
|
-
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
|
|
55898
|
-
}
|
|
55899
|
-
]
|
|
55900
|
-
} : {},
|
|
55901
|
-
CustomErrorResponses: singlePageApp ? [
|
|
55902
|
-
{
|
|
55903
|
-
ErrorCode: 403,
|
|
55904
|
-
ResponseCode: 200,
|
|
55905
|
-
ResponsePagePath: `/${defaultRootObject}`,
|
|
55906
|
-
ErrorCachingMinTTL: 300
|
|
55907
|
-
},
|
|
55908
|
-
{
|
|
55909
|
-
ErrorCode: 404,
|
|
55910
|
-
ResponseCode: 200,
|
|
55911
|
-
ResponsePagePath: `/${defaultRootObject}`,
|
|
55912
|
-
ErrorCachingMinTTL: 300
|
|
55913
|
-
}
|
|
55914
|
-
] : [
|
|
55915
|
-
{
|
|
55916
|
-
ErrorCode: 403,
|
|
55917
|
-
ResponseCode: 404,
|
|
55918
|
-
ResponsePagePath: `/${errorDocument}`,
|
|
55919
|
-
ErrorCachingMinTTL: 300
|
|
55793
|
+
if (options?.MaxRecords) {
|
|
55794
|
+
params.MaxRecords = options.MaxRecords;
|
|
55795
|
+
}
|
|
55796
|
+
if (options?.Marker) {
|
|
55797
|
+
params.Marker = options.Marker;
|
|
55798
|
+
}
|
|
55799
|
+
if (options?.Filters) {
|
|
55800
|
+
options.Filters.forEach((filter, i) => {
|
|
55801
|
+
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
55802
|
+
filter.Values.forEach((value, j) => {
|
|
55803
|
+
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
55804
|
+
});
|
|
55805
|
+
});
|
|
55806
|
+
}
|
|
55807
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55808
|
+
const result = await this.client.request({
|
|
55809
|
+
service: "rds",
|
|
55810
|
+
region: this.region,
|
|
55811
|
+
method: "POST",
|
|
55812
|
+
path: "/",
|
|
55813
|
+
headers: {
|
|
55814
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55920
55815
|
},
|
|
55921
|
-
|
|
55922
|
-
|
|
55923
|
-
|
|
55924
|
-
|
|
55925
|
-
|
|
55926
|
-
|
|
55927
|
-
|
|
55928
|
-
|
|
55929
|
-
|
|
55930
|
-
|
|
55931
|
-
distributionConfig.ViewerCertificate = {
|
|
55932
|
-
AcmCertificateArn: certificateArn,
|
|
55933
|
-
SslSupportMethod: "sni-only",
|
|
55934
|
-
MinimumProtocolVersion: "TLSv1.2_2021"
|
|
55935
|
-
};
|
|
55936
|
-
} else {
|
|
55937
|
-
distributionConfig.ViewerCertificate = {
|
|
55938
|
-
CloudFrontDefaultCertificate: true
|
|
55816
|
+
body: queryString
|
|
55817
|
+
});
|
|
55818
|
+
const response = result.DescribeDBClustersResult || result;
|
|
55819
|
+
let clusters = response.DBClusters?.DBCluster || [];
|
|
55820
|
+
if (!Array.isArray(clusters)) {
|
|
55821
|
+
clusters = clusters ? [clusters] : [];
|
|
55822
|
+
}
|
|
55823
|
+
return {
|
|
55824
|
+
DBClusters: clusters,
|
|
55825
|
+
Marker: response.Marker
|
|
55939
55826
|
};
|
|
55940
55827
|
}
|
|
55941
|
-
|
|
55942
|
-
|
|
55943
|
-
|
|
55944
|
-
|
|
55945
|
-
|
|
55946
|
-
|
|
55947
|
-
|
|
55948
|
-
...!passthroughUrls ? ["UrlRewriteFunction"] : []
|
|
55949
|
-
],
|
|
55950
|
-
Properties: {
|
|
55951
|
-
DistributionConfig: distributionConfig
|
|
55952
|
-
}
|
|
55953
|
-
};
|
|
55954
|
-
outputs.DistributionId = {
|
|
55955
|
-
Description: "CloudFront Distribution ID",
|
|
55956
|
-
Value: { Ref: "CloudFrontDistribution" }
|
|
55957
|
-
};
|
|
55958
|
-
outputs.DistributionDomain = {
|
|
55959
|
-
Description: "CloudFront Distribution Domain",
|
|
55960
|
-
Value: { "Fn::GetAtt": ["CloudFrontDistribution", "DomainName"] }
|
|
55961
|
-
};
|
|
55962
|
-
resources.S3BucketPolicy = {
|
|
55963
|
-
Type: "AWS::S3::BucketPolicy",
|
|
55964
|
-
...retainPolicy,
|
|
55965
|
-
DependsOn: ["S3Bucket", "CloudFrontDistribution"],
|
|
55966
|
-
Properties: {
|
|
55967
|
-
Bucket: { Ref: "S3Bucket" },
|
|
55968
|
-
PolicyDocument: {
|
|
55969
|
-
Version: "2012-10-17",
|
|
55970
|
-
Statement: [
|
|
55971
|
-
{
|
|
55972
|
-
Sid: "AllowCloudFrontServicePrincipal",
|
|
55973
|
-
Effect: "Allow",
|
|
55974
|
-
Principal: {
|
|
55975
|
-
Service: "cloudfront.amazonaws.com"
|
|
55976
|
-
},
|
|
55977
|
-
Action: "s3:GetObject",
|
|
55978
|
-
Resource: { "Fn::Sub": "arn:aws:s3:::${S3Bucket}/*" },
|
|
55979
|
-
Condition: {
|
|
55980
|
-
StringEquals: {
|
|
55981
|
-
"AWS:SourceArn": {
|
|
55982
|
-
"Fn::Sub": "arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"
|
|
55983
|
-
}
|
|
55984
|
-
}
|
|
55985
|
-
}
|
|
55986
|
-
}
|
|
55987
|
-
]
|
|
55988
|
-
}
|
|
55828
|
+
async describeDBSnapshots(options) {
|
|
55829
|
+
const params = {
|
|
55830
|
+
Action: "DescribeDBSnapshots",
|
|
55831
|
+
Version: "2014-10-31"
|
|
55832
|
+
};
|
|
55833
|
+
if (options?.DBInstanceIdentifier) {
|
|
55834
|
+
params.DBInstanceIdentifier = options.DBInstanceIdentifier;
|
|
55989
55835
|
}
|
|
55990
|
-
|
|
55991
|
-
|
|
55992
|
-
Description: "Site URL",
|
|
55993
|
-
Value: domain ? `https://${domain}` : { "Fn::Sub": "https://${CloudFrontDistribution.DomainName}" }
|
|
55994
|
-
};
|
|
55995
|
-
return {
|
|
55996
|
-
AWSTemplateFormatVersion: "2010-09-09",
|
|
55997
|
-
Description: `Static site infrastructure for ${domain || bucketName} (External DNS)`,
|
|
55998
|
-
Resources: resources,
|
|
55999
|
-
Outputs: outputs
|
|
56000
|
-
};
|
|
56001
|
-
}
|
|
56002
|
-
async function deployStaticSiteWithExternalDns(config6) {
|
|
56003
|
-
const region = config6.region || "us-east-1";
|
|
56004
|
-
const cfRegion = "us-east-1";
|
|
56005
|
-
const domain = config6.domain;
|
|
56006
|
-
const bucket = config6.bucket || domain.replace(/\./g, "-");
|
|
56007
|
-
const stackName = config6.stackName || `${config6.siteName}-static-site`;
|
|
56008
|
-
const cf = new CloudFormationClient(cfRegion);
|
|
56009
|
-
const acm2 = new ACMClient("us-east-1");
|
|
56010
|
-
let dnsProvider = null;
|
|
56011
|
-
if (!config6.skipDnsVerification) {
|
|
56012
|
-
dnsProvider = createDnsProvider(config6.dnsProvider);
|
|
56013
|
-
console.log(`Verifying DNS provider can manage ${domain}...`);
|
|
56014
|
-
const verify = await dnsProvider.listRecords(domain);
|
|
56015
|
-
if (!verify.success) {
|
|
56016
|
-
const reason = verify.message || "unknown error — check API credentials and domain ownership";
|
|
56017
|
-
return {
|
|
56018
|
-
success: false,
|
|
56019
|
-
stackName,
|
|
56020
|
-
bucket,
|
|
56021
|
-
message: `DNS provider '${dnsProvider.name}' cannot manage domain ${domain}: ${reason}`
|
|
56022
|
-
};
|
|
55836
|
+
if (options?.DBSnapshotIdentifier) {
|
|
55837
|
+
params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
|
|
56023
55838
|
}
|
|
56024
|
-
|
|
56025
|
-
|
|
56026
|
-
console.log(`Skipping DNS verification for ${domain}`);
|
|
56027
|
-
}
|
|
56028
|
-
let certificateArn = config6.certificateArn;
|
|
56029
|
-
const domainParts = domain.split(".");
|
|
56030
|
-
const isApexDomain = domainParts.length === 2;
|
|
56031
|
-
const wwwDomain = isApexDomain ? `www.${domain}` : undefined;
|
|
56032
|
-
if (!certificateArn) {
|
|
56033
|
-
console.log(`Checking for existing SSL certificate for ${domain}...`);
|
|
56034
|
-
const existingCert = await acm2.findCertificateByDomain(domain);
|
|
56035
|
-
let existingCertCoversWww = false;
|
|
56036
|
-
if (existingCert && existingCert.Status === "ISSUED") {
|
|
56037
|
-
if (wwwDomain && existingCert.SubjectAlternativeNames) {
|
|
56038
|
-
existingCertCoversWww = existingCert.SubjectAlternativeNames.includes(wwwDomain) || existingCert.SubjectAlternativeNames.some((san) => san === `*.${domain}`);
|
|
56039
|
-
} else {
|
|
56040
|
-
existingCertCoversWww = true;
|
|
56041
|
-
}
|
|
56042
|
-
if (existingCertCoversWww) {
|
|
56043
|
-
certificateArn = existingCert.CertificateArn;
|
|
56044
|
-
console.log(`Found existing certificate with www coverage: ${certificateArn}`);
|
|
56045
|
-
} else {
|
|
56046
|
-
console.log(`Existing certificate doesn't cover ${wwwDomain}, requesting new one...`);
|
|
56047
|
-
}
|
|
55839
|
+
if (options?.SnapshotType) {
|
|
55840
|
+
params.SnapshotType = options.SnapshotType;
|
|
56048
55841
|
}
|
|
56049
|
-
if (
|
|
56050
|
-
|
|
56051
|
-
return {
|
|
56052
|
-
success: false,
|
|
56053
|
-
stackName,
|
|
56054
|
-
bucket,
|
|
56055
|
-
message: `No DNS provider available to validate SSL certificate for ${domain}. Provide a certificateArn or enable DNS verification.`
|
|
56056
|
-
};
|
|
56057
|
-
}
|
|
56058
|
-
console.log(`Requesting new SSL certificate for ${domain}${wwwDomain ? ` (including ${wwwDomain})` : ""}...`);
|
|
56059
|
-
const validator = new UnifiedDnsValidator(dnsProvider, "us-east-1");
|
|
56060
|
-
const certResult = await validator.findOrCreateCertificate({
|
|
56061
|
-
domainName: domain,
|
|
56062
|
-
subjectAlternativeNames: wwwDomain ? [wwwDomain] : undefined,
|
|
56063
|
-
waitForValidation: true,
|
|
56064
|
-
maxWaitMinutes: 10
|
|
56065
|
-
});
|
|
56066
|
-
if (certResult.status !== "issued") {
|
|
56067
|
-
return {
|
|
56068
|
-
success: false,
|
|
56069
|
-
stackName,
|
|
56070
|
-
bucket,
|
|
56071
|
-
message: `SSL certificate validation failed. Status: ${certResult.status}`
|
|
56072
|
-
};
|
|
56073
|
-
}
|
|
56074
|
-
certificateArn = certResult.certificateArn;
|
|
56075
|
-
console.log(`Certificate issued: ${certificateArn}`);
|
|
55842
|
+
if (options?.MaxRecords) {
|
|
55843
|
+
params.MaxRecords = options.MaxRecords;
|
|
56076
55844
|
}
|
|
56077
|
-
|
|
56078
|
-
|
|
56079
|
-
let existingBucketName;
|
|
56080
|
-
try {
|
|
56081
|
-
const existingStacks = await cf.describeStacks({ stackName });
|
|
56082
|
-
if (existingStacks.Stacks.length > 0) {
|
|
56083
|
-
const stack = existingStacks.Stacks[0];
|
|
56084
|
-
const stackStatus = stack.StackStatus;
|
|
56085
|
-
if (stackStatus === "DELETE_IN_PROGRESS") {
|
|
56086
|
-
console.log("Previous stack is still being deleted, waiting...");
|
|
56087
|
-
await cf.waitForStack(stackName, "stack-delete-complete");
|
|
56088
|
-
stackExists = false;
|
|
56089
|
-
} else if (stackStatus === "DELETE_COMPLETE") {
|
|
56090
|
-
stackExists = false;
|
|
56091
|
-
} else {
|
|
56092
|
-
stackExists = true;
|
|
56093
|
-
const outputs2 = stack.Outputs || [];
|
|
56094
|
-
existingBucketName = outputs2.find((o) => o.OutputKey === "BucketName")?.OutputValue;
|
|
56095
|
-
}
|
|
55845
|
+
if (options?.Marker) {
|
|
55846
|
+
params.Marker = options.Marker;
|
|
56096
55847
|
}
|
|
56097
|
-
|
|
56098
|
-
|
|
56099
|
-
|
|
56100
|
-
|
|
56101
|
-
|
|
55848
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55849
|
+
const result = await this.client.request({
|
|
55850
|
+
service: "rds",
|
|
55851
|
+
region: this.region,
|
|
55852
|
+
method: "POST",
|
|
55853
|
+
path: "/",
|
|
55854
|
+
headers: {
|
|
55855
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55856
|
+
},
|
|
55857
|
+
body: queryString
|
|
55858
|
+
});
|
|
55859
|
+
const response = result.DescribeDBSnapshotsResult || result;
|
|
55860
|
+
let snapshots = response.DBSnapshots?.DBSnapshot || [];
|
|
55861
|
+
if (!Array.isArray(snapshots)) {
|
|
55862
|
+
snapshots = snapshots ? [snapshots] : [];
|
|
56102
55863
|
}
|
|
55864
|
+
return {
|
|
55865
|
+
DBSnapshots: snapshots,
|
|
55866
|
+
Marker: response.Marker
|
|
55867
|
+
};
|
|
56103
55868
|
}
|
|
56104
|
-
|
|
56105
|
-
|
|
56106
|
-
|
|
56107
|
-
|
|
55869
|
+
async describeDBSubnetGroups(options) {
|
|
55870
|
+
const params = {
|
|
55871
|
+
Action: "DescribeDBSubnetGroups",
|
|
55872
|
+
Version: "2014-10-31"
|
|
55873
|
+
};
|
|
55874
|
+
if (options?.DBSubnetGroupName) {
|
|
55875
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
55876
|
+
}
|
|
55877
|
+
if (options?.MaxRecords) {
|
|
55878
|
+
params.MaxRecords = options.MaxRecords;
|
|
55879
|
+
}
|
|
55880
|
+
if (options?.Marker) {
|
|
55881
|
+
params.Marker = options.Marker;
|
|
55882
|
+
}
|
|
55883
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55884
|
+
const result = await this.client.request({
|
|
55885
|
+
service: "rds",
|
|
55886
|
+
region: this.region,
|
|
55887
|
+
method: "POST",
|
|
55888
|
+
path: "/",
|
|
55889
|
+
headers: {
|
|
55890
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55891
|
+
},
|
|
55892
|
+
body: queryString
|
|
55893
|
+
});
|
|
55894
|
+
const response = result.DescribeDBSubnetGroupsResult || result;
|
|
55895
|
+
let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
|
|
55896
|
+
if (!Array.isArray(groups)) {
|
|
55897
|
+
groups = groups ? [groups] : [];
|
|
55898
|
+
}
|
|
55899
|
+
return {
|
|
55900
|
+
DBSubnetGroups: groups,
|
|
55901
|
+
Marker: response.Marker
|
|
55902
|
+
};
|
|
55903
|
+
}
|
|
55904
|
+
async createDBInstance(options) {
|
|
55905
|
+
const params = {
|
|
55906
|
+
Action: "CreateDBInstance",
|
|
55907
|
+
Version: "2014-10-31",
|
|
55908
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
55909
|
+
DBInstanceClass: options.DBInstanceClass,
|
|
55910
|
+
Engine: options.Engine
|
|
55911
|
+
};
|
|
55912
|
+
if (options.MasterUsername)
|
|
55913
|
+
params.MasterUsername = options.MasterUsername;
|
|
55914
|
+
if (options.MasterUserPassword)
|
|
55915
|
+
params.MasterUserPassword = options.MasterUserPassword;
|
|
55916
|
+
if (options.DBName)
|
|
55917
|
+
params.DBName = options.DBName;
|
|
55918
|
+
if (options.AllocatedStorage)
|
|
55919
|
+
params.AllocatedStorage = options.AllocatedStorage;
|
|
55920
|
+
if (options.DBSubnetGroupName)
|
|
55921
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
55922
|
+
if (options.AvailabilityZone)
|
|
55923
|
+
params.AvailabilityZone = options.AvailabilityZone;
|
|
55924
|
+
if (options.PreferredMaintenanceWindow)
|
|
55925
|
+
params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
|
|
55926
|
+
if (options.PreferredBackupWindow)
|
|
55927
|
+
params.PreferredBackupWindow = options.PreferredBackupWindow;
|
|
55928
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
55929
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
55930
|
+
if (options.MultiAZ !== undefined)
|
|
55931
|
+
params.MultiAZ = options.MultiAZ;
|
|
55932
|
+
if (options.EngineVersion)
|
|
55933
|
+
params.EngineVersion = options.EngineVersion;
|
|
55934
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
55935
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
55936
|
+
if (options.LicenseModel)
|
|
55937
|
+
params.LicenseModel = options.LicenseModel;
|
|
55938
|
+
if (options.PubliclyAccessible !== undefined)
|
|
55939
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
55940
|
+
if (options.StorageType)
|
|
55941
|
+
params.StorageType = options.StorageType;
|
|
55942
|
+
if (options.StorageEncrypted !== undefined)
|
|
55943
|
+
params.StorageEncrypted = options.StorageEncrypted;
|
|
55944
|
+
if (options.KmsKeyId)
|
|
55945
|
+
params.KmsKeyId = options.KmsKeyId;
|
|
55946
|
+
if (options.DeletionProtection !== undefined)
|
|
55947
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
55948
|
+
if (options.VpcSecurityGroupIds) {
|
|
55949
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
55950
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
55951
|
+
});
|
|
55952
|
+
}
|
|
55953
|
+
if (options.Tags) {
|
|
55954
|
+
options.Tags.forEach((tag, i) => {
|
|
55955
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
55956
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
55957
|
+
});
|
|
55958
|
+
}
|
|
55959
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55960
|
+
const result = await this.client.request({
|
|
55961
|
+
service: "rds",
|
|
55962
|
+
region: this.region,
|
|
55963
|
+
method: "POST",
|
|
55964
|
+
path: "/",
|
|
55965
|
+
headers: {
|
|
55966
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55967
|
+
},
|
|
55968
|
+
body: queryString
|
|
55969
|
+
});
|
|
55970
|
+
const response = result.CreateDBInstanceResult || result;
|
|
55971
|
+
return {
|
|
55972
|
+
DBInstance: response.DBInstance
|
|
55973
|
+
};
|
|
55974
|
+
}
|
|
55975
|
+
async deleteDBInstance(options) {
|
|
55976
|
+
const params = {
|
|
55977
|
+
Action: "DeleteDBInstance",
|
|
55978
|
+
Version: "2014-10-31",
|
|
55979
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
55980
|
+
};
|
|
55981
|
+
if (options.SkipFinalSnapshot !== undefined) {
|
|
55982
|
+
params.SkipFinalSnapshot = options.SkipFinalSnapshot;
|
|
55983
|
+
}
|
|
55984
|
+
if (options.FinalDBSnapshotIdentifier) {
|
|
55985
|
+
params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
|
|
55986
|
+
}
|
|
55987
|
+
if (options.DeleteAutomatedBackups !== undefined) {
|
|
55988
|
+
params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
|
|
55989
|
+
}
|
|
55990
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
55991
|
+
const result = await this.client.request({
|
|
55992
|
+
service: "rds",
|
|
55993
|
+
region: this.region,
|
|
55994
|
+
method: "POST",
|
|
55995
|
+
path: "/",
|
|
55996
|
+
headers: {
|
|
55997
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
55998
|
+
},
|
|
55999
|
+
body: queryString
|
|
56000
|
+
});
|
|
56001
|
+
const response = result.DeleteDBInstanceResult || result;
|
|
56002
|
+
return {
|
|
56003
|
+
DBInstance: response.DBInstance
|
|
56004
|
+
};
|
|
56005
|
+
}
|
|
56006
|
+
async modifyDBInstance(options) {
|
|
56007
|
+
const params = {
|
|
56008
|
+
Action: "ModifyDBInstance",
|
|
56009
|
+
Version: "2014-10-31",
|
|
56010
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
56011
|
+
};
|
|
56012
|
+
if (options.DBInstanceClass)
|
|
56013
|
+
params.DBInstanceClass = options.DBInstanceClass;
|
|
56014
|
+
if (options.AllocatedStorage)
|
|
56015
|
+
params.AllocatedStorage = options.AllocatedStorage;
|
|
56016
|
+
if (options.MasterUserPassword)
|
|
56017
|
+
params.MasterUserPassword = options.MasterUserPassword;
|
|
56018
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
56019
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
56020
|
+
if (options.PreferredBackupWindow)
|
|
56021
|
+
params.PreferredBackupWindow = options.PreferredBackupWindow;
|
|
56022
|
+
if (options.PreferredMaintenanceWindow)
|
|
56023
|
+
params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
|
|
56024
|
+
if (options.MultiAZ !== undefined)
|
|
56025
|
+
params.MultiAZ = options.MultiAZ;
|
|
56026
|
+
if (options.EngineVersion)
|
|
56027
|
+
params.EngineVersion = options.EngineVersion;
|
|
56028
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
56029
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
56030
|
+
if (options.PubliclyAccessible !== undefined)
|
|
56031
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
56032
|
+
if (options.ApplyImmediately !== undefined)
|
|
56033
|
+
params.ApplyImmediately = options.ApplyImmediately;
|
|
56034
|
+
if (options.StorageType)
|
|
56035
|
+
params.StorageType = options.StorageType;
|
|
56036
|
+
if (options.DeletionProtection !== undefined)
|
|
56037
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
56038
|
+
if (options.VpcSecurityGroupIds) {
|
|
56039
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
56040
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
56041
|
+
});
|
|
56042
|
+
}
|
|
56043
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56044
|
+
const result = await this.client.request({
|
|
56045
|
+
service: "rds",
|
|
56046
|
+
region: this.region,
|
|
56047
|
+
method: "POST",
|
|
56048
|
+
path: "/",
|
|
56049
|
+
headers: {
|
|
56050
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56051
|
+
},
|
|
56052
|
+
body: queryString
|
|
56053
|
+
});
|
|
56054
|
+
const response = result.ModifyDBInstanceResult || result;
|
|
56055
|
+
return {
|
|
56056
|
+
DBInstance: response.DBInstance
|
|
56057
|
+
};
|
|
56058
|
+
}
|
|
56059
|
+
async modifyDBCluster(options) {
|
|
56060
|
+
const params = {
|
|
56061
|
+
Action: "ModifyDBCluster",
|
|
56062
|
+
Version: "2014-10-31",
|
|
56063
|
+
DBClusterIdentifier: options.DBClusterIdentifier
|
|
56064
|
+
};
|
|
56065
|
+
if (options.ServerlessV2ScalingConfiguration) {
|
|
56066
|
+
params["ServerlessV2ScalingConfiguration.MinCapacity"] = options.ServerlessV2ScalingConfiguration.MinCapacity;
|
|
56067
|
+
params["ServerlessV2ScalingConfiguration.MaxCapacity"] = options.ServerlessV2ScalingConfiguration.MaxCapacity;
|
|
56068
|
+
}
|
|
56069
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
56070
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
56071
|
+
if (options.ApplyImmediately !== undefined)
|
|
56072
|
+
params.ApplyImmediately = options.ApplyImmediately;
|
|
56073
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56074
|
+
const result = await this.client.request({
|
|
56075
|
+
service: "rds",
|
|
56076
|
+
region: this.region,
|
|
56077
|
+
method: "POST",
|
|
56078
|
+
path: "/",
|
|
56079
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
56080
|
+
body: queryString
|
|
56081
|
+
});
|
|
56082
|
+
const response = result.ModifyDBClusterResult || result;
|
|
56083
|
+
return { DBCluster: response.DBCluster };
|
|
56084
|
+
}
|
|
56085
|
+
async restoreDBClusterToPointInTime(options) {
|
|
56086
|
+
const params = {
|
|
56087
|
+
Action: "RestoreDBClusterToPointInTime",
|
|
56088
|
+
Version: "2014-10-31",
|
|
56089
|
+
DBClusterIdentifier: options.DBClusterIdentifier,
|
|
56090
|
+
SourceDBClusterIdentifier: options.SourceDBClusterIdentifier
|
|
56091
|
+
};
|
|
56092
|
+
if (options.RestoreToTime)
|
|
56093
|
+
params.RestoreToTime = options.RestoreToTime.toISOString();
|
|
56094
|
+
if (options.UseLatestRestorableTime)
|
|
56095
|
+
params.UseLatestRestorableTime = true;
|
|
56096
|
+
if (options.DBSubnetGroupName)
|
|
56097
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
56098
|
+
if (options.VpcSecurityGroupIds) {
|
|
56099
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
56100
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
56101
|
+
});
|
|
56102
|
+
}
|
|
56103
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56104
|
+
const result = await this.client.request({
|
|
56105
|
+
service: "rds",
|
|
56106
|
+
region: this.region,
|
|
56107
|
+
method: "POST",
|
|
56108
|
+
path: "/",
|
|
56109
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
56110
|
+
body: queryString
|
|
56111
|
+
});
|
|
56112
|
+
const response = result.RestoreDBClusterToPointInTimeResult || result;
|
|
56113
|
+
return { DBCluster: response.DBCluster };
|
|
56114
|
+
}
|
|
56115
|
+
async startDBInstance(dbInstanceIdentifier) {
|
|
56116
|
+
const params = {
|
|
56117
|
+
Action: "StartDBInstance",
|
|
56118
|
+
Version: "2014-10-31",
|
|
56119
|
+
DBInstanceIdentifier: dbInstanceIdentifier
|
|
56120
|
+
};
|
|
56121
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56122
|
+
const result = await this.client.request({
|
|
56123
|
+
service: "rds",
|
|
56124
|
+
region: this.region,
|
|
56125
|
+
method: "POST",
|
|
56126
|
+
path: "/",
|
|
56127
|
+
headers: {
|
|
56128
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56129
|
+
},
|
|
56130
|
+
body: queryString
|
|
56131
|
+
});
|
|
56132
|
+
const response = result.StartDBInstanceResult || result;
|
|
56133
|
+
return {
|
|
56134
|
+
DBInstance: response.DBInstance
|
|
56135
|
+
};
|
|
56136
|
+
}
|
|
56137
|
+
async stopDBInstance(options) {
|
|
56138
|
+
const params = {
|
|
56139
|
+
Action: "StopDBInstance",
|
|
56140
|
+
Version: "2014-10-31",
|
|
56141
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
56142
|
+
};
|
|
56143
|
+
if (options.DBSnapshotIdentifier) {
|
|
56144
|
+
params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
|
|
56145
|
+
}
|
|
56146
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56147
|
+
const result = await this.client.request({
|
|
56148
|
+
service: "rds",
|
|
56149
|
+
region: this.region,
|
|
56150
|
+
method: "POST",
|
|
56151
|
+
path: "/",
|
|
56152
|
+
headers: {
|
|
56153
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56154
|
+
},
|
|
56155
|
+
body: queryString
|
|
56156
|
+
});
|
|
56157
|
+
const response = result.StopDBInstanceResult || result;
|
|
56158
|
+
return {
|
|
56159
|
+
DBInstance: response.DBInstance
|
|
56160
|
+
};
|
|
56161
|
+
}
|
|
56162
|
+
async rebootDBInstance(options) {
|
|
56163
|
+
const params = {
|
|
56164
|
+
Action: "RebootDBInstance",
|
|
56165
|
+
Version: "2014-10-31",
|
|
56166
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
56167
|
+
};
|
|
56168
|
+
if (options.ForceFailover !== undefined) {
|
|
56169
|
+
params.ForceFailover = options.ForceFailover;
|
|
56170
|
+
}
|
|
56171
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56172
|
+
const result = await this.client.request({
|
|
56173
|
+
service: "rds",
|
|
56174
|
+
region: this.region,
|
|
56175
|
+
method: "POST",
|
|
56176
|
+
path: "/",
|
|
56177
|
+
headers: {
|
|
56178
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56179
|
+
},
|
|
56180
|
+
body: queryString
|
|
56181
|
+
});
|
|
56182
|
+
const response = result.RebootDBInstanceResult || result;
|
|
56183
|
+
return {
|
|
56184
|
+
DBInstance: response.DBInstance
|
|
56185
|
+
};
|
|
56186
|
+
}
|
|
56187
|
+
async createDBSnapshot(options) {
|
|
56188
|
+
const params = {
|
|
56189
|
+
Action: "CreateDBSnapshot",
|
|
56190
|
+
Version: "2014-10-31",
|
|
56191
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
56192
|
+
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
56193
|
+
};
|
|
56194
|
+
if (options.Tags) {
|
|
56195
|
+
options.Tags.forEach((tag, i) => {
|
|
56196
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
56197
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
56198
|
+
});
|
|
56199
|
+
}
|
|
56200
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56201
|
+
const result = await this.client.request({
|
|
56202
|
+
service: "rds",
|
|
56203
|
+
region: this.region,
|
|
56204
|
+
method: "POST",
|
|
56205
|
+
path: "/",
|
|
56206
|
+
headers: {
|
|
56207
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56208
|
+
},
|
|
56209
|
+
body: queryString
|
|
56210
|
+
});
|
|
56211
|
+
const response = result.CreateDBSnapshotResult || result;
|
|
56212
|
+
return {
|
|
56213
|
+
DBSnapshot: response.DBSnapshot
|
|
56214
|
+
};
|
|
56215
|
+
}
|
|
56216
|
+
async deleteDBSnapshot(dbSnapshotIdentifier) {
|
|
56217
|
+
const params = {
|
|
56218
|
+
Action: "DeleteDBSnapshot",
|
|
56219
|
+
Version: "2014-10-31",
|
|
56220
|
+
DBSnapshotIdentifier: dbSnapshotIdentifier
|
|
56221
|
+
};
|
|
56222
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56223
|
+
const result = await this.client.request({
|
|
56224
|
+
service: "rds",
|
|
56225
|
+
region: this.region,
|
|
56226
|
+
method: "POST",
|
|
56227
|
+
path: "/",
|
|
56228
|
+
headers: {
|
|
56229
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56230
|
+
},
|
|
56231
|
+
body: queryString
|
|
56232
|
+
});
|
|
56233
|
+
const response = result.DeleteDBSnapshotResult || result;
|
|
56234
|
+
return {
|
|
56235
|
+
DBSnapshot: response.DBSnapshot
|
|
56236
|
+
};
|
|
56237
|
+
}
|
|
56238
|
+
async restoreDBInstanceFromDBSnapshot(options) {
|
|
56239
|
+
const params = {
|
|
56240
|
+
Action: "RestoreDBInstanceFromDBSnapshot",
|
|
56241
|
+
Version: "2014-10-31",
|
|
56242
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
56243
|
+
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
56244
|
+
};
|
|
56245
|
+
if (options.DBInstanceClass)
|
|
56246
|
+
params.DBInstanceClass = options.DBInstanceClass;
|
|
56247
|
+
if (options.Port)
|
|
56248
|
+
params.Port = options.Port;
|
|
56249
|
+
if (options.AvailabilityZone)
|
|
56250
|
+
params.AvailabilityZone = options.AvailabilityZone;
|
|
56251
|
+
if (options.DBSubnetGroupName)
|
|
56252
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
56253
|
+
if (options.MultiAZ !== undefined)
|
|
56254
|
+
params.MultiAZ = options.MultiAZ;
|
|
56255
|
+
if (options.PubliclyAccessible !== undefined)
|
|
56256
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
56257
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
56258
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
56259
|
+
if (options.StorageType)
|
|
56260
|
+
params.StorageType = options.StorageType;
|
|
56261
|
+
if (options.DeletionProtection !== undefined)
|
|
56262
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
56263
|
+
if (options.VpcSecurityGroupIds) {
|
|
56264
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
56265
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
56266
|
+
});
|
|
56267
|
+
}
|
|
56268
|
+
if (options.Tags) {
|
|
56269
|
+
options.Tags.forEach((tag, i) => {
|
|
56270
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
56271
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
56272
|
+
});
|
|
56273
|
+
}
|
|
56274
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
56275
|
+
const result = await this.client.request({
|
|
56276
|
+
service: "rds",
|
|
56277
|
+
region: this.region,
|
|
56278
|
+
method: "POST",
|
|
56279
|
+
path: "/",
|
|
56280
|
+
headers: {
|
|
56281
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
56282
|
+
},
|
|
56283
|
+
body: queryString
|
|
56284
|
+
});
|
|
56285
|
+
const response = result.RestoreDBInstanceFromDBSnapshotResult || result;
|
|
56286
|
+
return {
|
|
56287
|
+
DBInstance: response.DBInstance
|
|
56288
|
+
};
|
|
56289
|
+
}
|
|
56290
|
+
async waitForDBInstanceAvailable(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
|
|
56291
|
+
for (let i = 0;i < maxAttempts; i++) {
|
|
56292
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
56293
|
+
if (instance?.DBInstanceStatus === "available") {
|
|
56294
|
+
return instance;
|
|
56295
|
+
}
|
|
56296
|
+
if (["deleted", "failed", "incompatible-restore", "incompatible-parameters"].includes(instance?.DBInstanceStatus || "")) {
|
|
56297
|
+
throw new Error(`DB instance ${dbInstanceIdentifier} is in terminal state: ${instance?.DBInstanceStatus}`);
|
|
56298
|
+
}
|
|
56299
|
+
await new Promise((resolve14) => setTimeout(resolve14, delayMs));
|
|
56300
|
+
}
|
|
56301
|
+
throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to become available`);
|
|
56302
|
+
}
|
|
56303
|
+
async waitForDBInstanceDeleted(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
|
|
56304
|
+
for (let i = 0;i < maxAttempts; i++) {
|
|
56305
|
+
try {
|
|
56306
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
56307
|
+
if (instance?.DBInstanceStatus === "deleting") {
|
|
56308
|
+
await new Promise((resolve14) => setTimeout(resolve14, delayMs));
|
|
56309
|
+
continue;
|
|
56310
|
+
}
|
|
56311
|
+
throw new Error(`DB instance ${dbInstanceIdentifier} is in state: ${instance?.DBInstanceStatus}`);
|
|
56312
|
+
} catch (error) {
|
|
56313
|
+
if (error.code === "DBInstanceNotFound" || error.code === "DBInstanceNotFoundFault") {
|
|
56314
|
+
return;
|
|
56315
|
+
}
|
|
56316
|
+
throw error;
|
|
56317
|
+
}
|
|
56318
|
+
}
|
|
56319
|
+
throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to be deleted`);
|
|
56320
|
+
}
|
|
56321
|
+
}
|
|
56322
|
+
var init_rds = __esm(() => {
|
|
56323
|
+
init_client();
|
|
56324
|
+
});
|
|
56325
|
+
|
|
56326
|
+
// src/deploy/static-site-external-dns.ts
|
|
56327
|
+
function generateExternalDnsStaticSiteTemplate(config6) {
|
|
56328
|
+
const {
|
|
56329
|
+
bucketName,
|
|
56330
|
+
domain,
|
|
56331
|
+
aliases,
|
|
56332
|
+
certificateArn,
|
|
56333
|
+
defaultRootObject = "index.html",
|
|
56334
|
+
errorDocument = "404.html",
|
|
56335
|
+
passthroughUrls = false,
|
|
56336
|
+
singlePageApp = false,
|
|
56337
|
+
dynamicApp = false,
|
|
56338
|
+
computeOriginDomain,
|
|
56339
|
+
computeOriginPort = 3008,
|
|
56340
|
+
computeOriginId = "app-compute",
|
|
56341
|
+
retainOnStackDelete = false
|
|
56342
|
+
} = config6;
|
|
56343
|
+
const retainPolicy = retainOnStackDelete ? { DeletionPolicy: "Retain", UpdateReplacePolicy: "Retain" } : {};
|
|
56344
|
+
const useComputeOrigin = dynamicApp && !!computeOriginDomain;
|
|
56345
|
+
const defaultAllowedMethods = useComputeOrigin ? ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] : ["GET", "HEAD"];
|
|
56346
|
+
const defaultCachedMethods = useComputeOrigin ? ["GET", "HEAD"] : ["GET", "HEAD"];
|
|
56347
|
+
const resources = {};
|
|
56348
|
+
const outputs = {};
|
|
56349
|
+
resources.S3Bucket = {
|
|
56350
|
+
Type: "AWS::S3::Bucket",
|
|
56351
|
+
...retainPolicy,
|
|
56352
|
+
Properties: {
|
|
56353
|
+
BucketName: bucketName,
|
|
56354
|
+
PublicAccessBlockConfiguration: {
|
|
56355
|
+
BlockPublicAcls: true,
|
|
56356
|
+
BlockPublicPolicy: false,
|
|
56357
|
+
IgnorePublicAcls: true,
|
|
56358
|
+
RestrictPublicBuckets: false
|
|
56359
|
+
},
|
|
56360
|
+
WebsiteConfiguration: {
|
|
56361
|
+
IndexDocument: defaultRootObject,
|
|
56362
|
+
ErrorDocument: errorDocument
|
|
56363
|
+
}
|
|
56364
|
+
}
|
|
56365
|
+
};
|
|
56366
|
+
outputs.BucketName = {
|
|
56367
|
+
Description: "S3 Bucket Name",
|
|
56368
|
+
Value: { Ref: "S3Bucket" }
|
|
56369
|
+
};
|
|
56370
|
+
outputs.BucketArn = {
|
|
56371
|
+
Description: "S3 Bucket ARN",
|
|
56372
|
+
Value: { "Fn::GetAtt": ["S3Bucket", "Arn"] }
|
|
56373
|
+
};
|
|
56374
|
+
resources.CloudFrontOAC = {
|
|
56375
|
+
Type: "AWS::CloudFront::OriginAccessControl",
|
|
56376
|
+
...retainPolicy,
|
|
56377
|
+
Properties: {
|
|
56378
|
+
OriginAccessControlConfig: {
|
|
56379
|
+
Name: `OAC-${bucketName}`,
|
|
56380
|
+
Description: `OAC for ${bucketName}`,
|
|
56381
|
+
OriginAccessControlOriginType: "s3",
|
|
56382
|
+
SigningBehavior: "always",
|
|
56383
|
+
SigningProtocol: "sigv4"
|
|
56384
|
+
}
|
|
56385
|
+
}
|
|
56386
|
+
};
|
|
56387
|
+
let installRootRedirectLogicalId;
|
|
56388
|
+
if (passthroughUrls && useComputeOrigin) {
|
|
56389
|
+
installRootRedirectLogicalId = "InstallRootRedirectFunction";
|
|
56390
|
+
resources[installRootRedirectLogicalId] = {
|
|
56391
|
+
Type: "AWS::CloudFront::Function",
|
|
56392
|
+
Properties: {
|
|
56393
|
+
Name: { "Fn::Sub": "${AWS::StackName}-install-root-redirect" },
|
|
56394
|
+
AutoPublish: true,
|
|
56395
|
+
FunctionConfig: {
|
|
56396
|
+
Comment: "Redirect curl pantry.dev | bash (GET /) to /install.sh on S3",
|
|
56397
|
+
Runtime: "cloudfront-js-2.0"
|
|
56398
|
+
},
|
|
56399
|
+
FunctionCode: `function handler(event) {
|
|
56400
|
+
var request = event.request;
|
|
56401
|
+
if (request.uri === '/' || request.uri === '') {
|
|
56402
|
+
return {
|
|
56403
|
+
statusCode: 302,
|
|
56404
|
+
statusDescription: 'Found',
|
|
56405
|
+
headers: {
|
|
56406
|
+
location: { value: 'https://' + request.headers.host.value + '/install.sh' }
|
|
56407
|
+
}
|
|
56408
|
+
};
|
|
56409
|
+
}
|
|
56410
|
+
return request;
|
|
56411
|
+
}`
|
|
56412
|
+
}
|
|
56413
|
+
};
|
|
56414
|
+
}
|
|
56415
|
+
if (!passthroughUrls) {
|
|
56416
|
+
resources.UrlRewriteFunction = {
|
|
56417
|
+
Type: "AWS::CloudFront::Function",
|
|
56418
|
+
Properties: {
|
|
56419
|
+
Name: { "Fn::Sub": "${AWS::StackName}-url-rewrite" },
|
|
56420
|
+
AutoPublish: true,
|
|
56421
|
+
FunctionConfig: {
|
|
56422
|
+
Comment: "Append .html extension to URLs without extensions",
|
|
56423
|
+
Runtime: "cloudfront-js-2.0"
|
|
56424
|
+
},
|
|
56425
|
+
FunctionCode: `function handler(event) {
|
|
56426
|
+
const request = event.request;
|
|
56427
|
+
var uri = request.uri;
|
|
56428
|
+
|
|
56429
|
+
// If URI ends with /, serve index.html
|
|
56430
|
+
if (uri.endsWith('/')) {
|
|
56431
|
+
request.uri = uri + 'index.html';
|
|
56432
|
+
}
|
|
56433
|
+
// If URI doesn't have an extension, append .html
|
|
56434
|
+
else if (!uri.includes('.')) {
|
|
56435
|
+
request.uri = uri + '.html';
|
|
56436
|
+
}
|
|
56437
|
+
|
|
56438
|
+
return request;
|
|
56439
|
+
}`
|
|
56440
|
+
}
|
|
56441
|
+
};
|
|
56442
|
+
}
|
|
56443
|
+
const s3Origin = {
|
|
56444
|
+
Id: `S3-${bucketName}`,
|
|
56445
|
+
DomainName: { "Fn::GetAtt": ["S3Bucket", "RegionalDomainName"] },
|
|
56446
|
+
S3OriginConfig: {
|
|
56447
|
+
OriginAccessIdentity: ""
|
|
56448
|
+
},
|
|
56449
|
+
OriginAccessControlId: { "Fn::GetAtt": ["CloudFrontOAC", "Id"] }
|
|
56450
|
+
};
|
|
56451
|
+
const computeOrigin = useComputeOrigin ? {
|
|
56452
|
+
Id: computeOriginId,
|
|
56453
|
+
DomainName: computeOriginDomain,
|
|
56454
|
+
CustomOriginConfig: {
|
|
56455
|
+
HTTPPort: computeOriginPort,
|
|
56456
|
+
HTTPSPort: 443,
|
|
56457
|
+
OriginProtocolPolicy: "http-only",
|
|
56458
|
+
OriginSSLProtocols: ["TLSv1.2"]
|
|
56459
|
+
}
|
|
56460
|
+
} : null;
|
|
56461
|
+
const defaultTargetOriginId = useComputeOrigin ? computeOriginId : `S3-${bucketName}`;
|
|
56462
|
+
const distributionConfig = {
|
|
56463
|
+
Enabled: true,
|
|
56464
|
+
DefaultRootObject: defaultRootObject,
|
|
56465
|
+
HttpVersion: "http2and3",
|
|
56466
|
+
IPV6Enabled: true,
|
|
56467
|
+
PriceClass: "PriceClass_100",
|
|
56468
|
+
Origins: computeOrigin ? [computeOrigin, s3Origin] : [s3Origin],
|
|
56469
|
+
DefaultCacheBehavior: {
|
|
56470
|
+
TargetOriginId: defaultTargetOriginId,
|
|
56471
|
+
ViewerProtocolPolicy: "redirect-to-https",
|
|
56472
|
+
AllowedMethods: defaultAllowedMethods,
|
|
56473
|
+
CachedMethods: defaultCachedMethods,
|
|
56474
|
+
Compress: true,
|
|
56475
|
+
...useComputeOrigin ? {
|
|
56476
|
+
CachePolicyId: "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
|
|
56477
|
+
OriginRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
|
|
56478
|
+
...passthroughUrls && installRootRedirectLogicalId ? {
|
|
56479
|
+
FunctionAssociations: [{
|
|
56480
|
+
EventType: "viewer-request",
|
|
56481
|
+
FunctionARN: { "Fn::GetAtt": [installRootRedirectLogicalId, "FunctionARN"] }
|
|
56482
|
+
}]
|
|
56483
|
+
} : {}
|
|
56484
|
+
} : {
|
|
56485
|
+
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6",
|
|
56486
|
+
...!passthroughUrls && {
|
|
56487
|
+
FunctionAssociations: [
|
|
56488
|
+
{
|
|
56489
|
+
EventType: "viewer-request",
|
|
56490
|
+
FunctionARN: { "Fn::GetAtt": ["UrlRewriteFunction", "FunctionARN"] }
|
|
56491
|
+
}
|
|
56492
|
+
]
|
|
56493
|
+
}
|
|
56494
|
+
}
|
|
56495
|
+
},
|
|
56496
|
+
...useComputeOrigin && passthroughUrls ? {
|
|
56497
|
+
CacheBehaviors: [
|
|
56498
|
+
{
|
|
56499
|
+
PathPattern: "/install.sh",
|
|
56500
|
+
TargetOriginId: `S3-${bucketName}`,
|
|
56501
|
+
ViewerProtocolPolicy: "redirect-to-https",
|
|
56502
|
+
AllowedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
56503
|
+
CachedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
56504
|
+
Compress: true,
|
|
56505
|
+
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
|
|
56506
|
+
}
|
|
56507
|
+
]
|
|
56508
|
+
} : {},
|
|
56509
|
+
CustomErrorResponses: singlePageApp ? [
|
|
56510
|
+
{
|
|
56511
|
+
ErrorCode: 403,
|
|
56512
|
+
ResponseCode: 200,
|
|
56513
|
+
ResponsePagePath: `/${defaultRootObject}`,
|
|
56514
|
+
ErrorCachingMinTTL: 300
|
|
56515
|
+
},
|
|
56516
|
+
{
|
|
56517
|
+
ErrorCode: 404,
|
|
56518
|
+
ResponseCode: 200,
|
|
56519
|
+
ResponsePagePath: `/${defaultRootObject}`,
|
|
56520
|
+
ErrorCachingMinTTL: 300
|
|
56521
|
+
}
|
|
56522
|
+
] : [
|
|
56523
|
+
{
|
|
56524
|
+
ErrorCode: 403,
|
|
56525
|
+
ResponseCode: 404,
|
|
56526
|
+
ResponsePagePath: `/${errorDocument}`,
|
|
56527
|
+
ErrorCachingMinTTL: 300
|
|
56528
|
+
},
|
|
56529
|
+
{
|
|
56530
|
+
ErrorCode: 404,
|
|
56531
|
+
ResponseCode: 404,
|
|
56532
|
+
ResponsePagePath: `/${errorDocument}`,
|
|
56533
|
+
ErrorCachingMinTTL: 300
|
|
56534
|
+
}
|
|
56535
|
+
]
|
|
56536
|
+
};
|
|
56537
|
+
if (domain && certificateArn) {
|
|
56538
|
+
distributionConfig.Aliases = aliases && aliases.length > 0 ? aliases : [domain];
|
|
56539
|
+
distributionConfig.ViewerCertificate = {
|
|
56540
|
+
AcmCertificateArn: certificateArn,
|
|
56541
|
+
SslSupportMethod: "sni-only",
|
|
56542
|
+
MinimumProtocolVersion: "TLSv1.2_2021"
|
|
56543
|
+
};
|
|
56544
|
+
} else {
|
|
56545
|
+
distributionConfig.ViewerCertificate = {
|
|
56546
|
+
CloudFrontDefaultCertificate: true
|
|
56547
|
+
};
|
|
56548
|
+
}
|
|
56549
|
+
resources.CloudFrontDistribution = {
|
|
56550
|
+
Type: "AWS::CloudFront::Distribution",
|
|
56551
|
+
...retainPolicy,
|
|
56552
|
+
DependsOn: [
|
|
56553
|
+
"S3Bucket",
|
|
56554
|
+
"CloudFrontOAC",
|
|
56555
|
+
...passthroughUrls && useComputeOrigin && installRootRedirectLogicalId ? [installRootRedirectLogicalId] : [],
|
|
56556
|
+
...!passthroughUrls ? ["UrlRewriteFunction"] : []
|
|
56557
|
+
],
|
|
56558
|
+
Properties: {
|
|
56559
|
+
DistributionConfig: distributionConfig
|
|
56560
|
+
}
|
|
56561
|
+
};
|
|
56562
|
+
outputs.DistributionId = {
|
|
56563
|
+
Description: "CloudFront Distribution ID",
|
|
56564
|
+
Value: { Ref: "CloudFrontDistribution" }
|
|
56565
|
+
};
|
|
56566
|
+
outputs.DistributionDomain = {
|
|
56567
|
+
Description: "CloudFront Distribution Domain",
|
|
56568
|
+
Value: { "Fn::GetAtt": ["CloudFrontDistribution", "DomainName"] }
|
|
56569
|
+
};
|
|
56570
|
+
resources.S3BucketPolicy = {
|
|
56571
|
+
Type: "AWS::S3::BucketPolicy",
|
|
56572
|
+
...retainPolicy,
|
|
56573
|
+
DependsOn: ["S3Bucket", "CloudFrontDistribution"],
|
|
56574
|
+
Properties: {
|
|
56575
|
+
Bucket: { Ref: "S3Bucket" },
|
|
56576
|
+
PolicyDocument: {
|
|
56577
|
+
Version: "2012-10-17",
|
|
56578
|
+
Statement: [
|
|
56579
|
+
{
|
|
56580
|
+
Sid: "AllowCloudFrontServicePrincipal",
|
|
56581
|
+
Effect: "Allow",
|
|
56582
|
+
Principal: {
|
|
56583
|
+
Service: "cloudfront.amazonaws.com"
|
|
56584
|
+
},
|
|
56585
|
+
Action: "s3:GetObject",
|
|
56586
|
+
Resource: { "Fn::Sub": "arn:aws:s3:::${S3Bucket}/*" },
|
|
56587
|
+
Condition: {
|
|
56588
|
+
StringEquals: {
|
|
56589
|
+
"AWS:SourceArn": {
|
|
56590
|
+
"Fn::Sub": "arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"
|
|
56591
|
+
}
|
|
56592
|
+
}
|
|
56593
|
+
}
|
|
56594
|
+
}
|
|
56595
|
+
]
|
|
56596
|
+
}
|
|
56597
|
+
}
|
|
56598
|
+
};
|
|
56599
|
+
outputs.SiteUrl = {
|
|
56600
|
+
Description: "Site URL",
|
|
56601
|
+
Value: domain ? `https://${domain}` : { "Fn::Sub": "https://${CloudFrontDistribution.DomainName}" }
|
|
56602
|
+
};
|
|
56603
|
+
return {
|
|
56604
|
+
AWSTemplateFormatVersion: "2010-09-09",
|
|
56605
|
+
Description: `Static site infrastructure for ${domain || bucketName} (External DNS)`,
|
|
56606
|
+
Resources: resources,
|
|
56607
|
+
Outputs: outputs
|
|
56608
|
+
};
|
|
56609
|
+
}
|
|
56610
|
+
async function deployStaticSiteWithExternalDns(config6) {
|
|
56611
|
+
const region = config6.region || "us-east-1";
|
|
56612
|
+
const cfRegion = "us-east-1";
|
|
56613
|
+
const domain = config6.domain;
|
|
56614
|
+
const bucket = config6.bucket || domain.replace(/\./g, "-");
|
|
56615
|
+
const stackName = config6.stackName || `${config6.siteName}-static-site`;
|
|
56616
|
+
const cf = new CloudFormationClient(cfRegion);
|
|
56617
|
+
const acm2 = new ACMClient("us-east-1");
|
|
56618
|
+
let dnsProvider = null;
|
|
56619
|
+
if (!config6.skipDnsVerification) {
|
|
56620
|
+
dnsProvider = createDnsProvider(config6.dnsProvider);
|
|
56621
|
+
console.log(`Verifying DNS provider can manage ${domain}...`);
|
|
56622
|
+
const verify = await dnsProvider.listRecords(domain);
|
|
56623
|
+
if (!verify.success) {
|
|
56624
|
+
const reason = verify.message || "unknown error — check API credentials and domain ownership";
|
|
56625
|
+
return {
|
|
56626
|
+
success: false,
|
|
56627
|
+
stackName,
|
|
56628
|
+
bucket,
|
|
56629
|
+
message: `DNS provider '${dnsProvider.name}' cannot manage domain ${domain}: ${reason}`
|
|
56630
|
+
};
|
|
56631
|
+
}
|
|
56632
|
+
console.log(`DNS provider '${dnsProvider.name}' verified for ${domain}`);
|
|
56633
|
+
} else {
|
|
56634
|
+
console.log(`Skipping DNS verification for ${domain}`);
|
|
56635
|
+
}
|
|
56636
|
+
let certificateArn = config6.certificateArn;
|
|
56637
|
+
const domainParts = domain.split(".");
|
|
56638
|
+
const isApexDomain = domainParts.length === 2;
|
|
56639
|
+
const wwwDomain = isApexDomain ? `www.${domain}` : undefined;
|
|
56640
|
+
if (!certificateArn) {
|
|
56641
|
+
console.log(`Checking for existing SSL certificate for ${domain}...`);
|
|
56642
|
+
const existingCert = await acm2.findCertificateByDomain(domain);
|
|
56643
|
+
let existingCertCoversWww = false;
|
|
56644
|
+
if (existingCert && existingCert.Status === "ISSUED") {
|
|
56645
|
+
if (wwwDomain && existingCert.SubjectAlternativeNames) {
|
|
56646
|
+
existingCertCoversWww = existingCert.SubjectAlternativeNames.includes(wwwDomain) || existingCert.SubjectAlternativeNames.some((san) => san === `*.${domain}`);
|
|
56647
|
+
} else {
|
|
56648
|
+
existingCertCoversWww = true;
|
|
56649
|
+
}
|
|
56650
|
+
if (existingCertCoversWww) {
|
|
56651
|
+
certificateArn = existingCert.CertificateArn;
|
|
56652
|
+
console.log(`Found existing certificate with www coverage: ${certificateArn}`);
|
|
56653
|
+
} else {
|
|
56654
|
+
console.log(`Existing certificate doesn't cover ${wwwDomain}, requesting new one...`);
|
|
56655
|
+
}
|
|
56656
|
+
}
|
|
56657
|
+
if (!certificateArn) {
|
|
56658
|
+
if (!dnsProvider) {
|
|
56659
|
+
return {
|
|
56660
|
+
success: false,
|
|
56661
|
+
stackName,
|
|
56662
|
+
bucket,
|
|
56663
|
+
message: `No DNS provider available to validate SSL certificate for ${domain}. Provide a certificateArn or enable DNS verification.`
|
|
56664
|
+
};
|
|
56665
|
+
}
|
|
56666
|
+
console.log(`Requesting new SSL certificate for ${domain}${wwwDomain ? ` (including ${wwwDomain})` : ""}...`);
|
|
56667
|
+
const validator = new UnifiedDnsValidator(dnsProvider, "us-east-1");
|
|
56668
|
+
const certResult = await validator.findOrCreateCertificate({
|
|
56669
|
+
domainName: domain,
|
|
56670
|
+
subjectAlternativeNames: wwwDomain ? [wwwDomain] : undefined,
|
|
56671
|
+
waitForValidation: true,
|
|
56672
|
+
maxWaitMinutes: 10
|
|
56673
|
+
});
|
|
56674
|
+
if (certResult.status !== "issued") {
|
|
56675
|
+
return {
|
|
56676
|
+
success: false,
|
|
56677
|
+
stackName,
|
|
56678
|
+
bucket,
|
|
56679
|
+
message: `SSL certificate validation failed. Status: ${certResult.status}`
|
|
56680
|
+
};
|
|
56681
|
+
}
|
|
56682
|
+
certificateArn = certResult.certificateArn;
|
|
56683
|
+
console.log(`Certificate issued: ${certificateArn}`);
|
|
56684
|
+
}
|
|
56685
|
+
}
|
|
56686
|
+
let stackExists = false;
|
|
56687
|
+
let existingBucketName;
|
|
56688
|
+
try {
|
|
56689
|
+
const existingStacks = await cf.describeStacks({ stackName });
|
|
56690
|
+
if (existingStacks.Stacks.length > 0) {
|
|
56691
|
+
const stack = existingStacks.Stacks[0];
|
|
56692
|
+
const stackStatus = stack.StackStatus;
|
|
56693
|
+
if (stackStatus === "DELETE_IN_PROGRESS") {
|
|
56694
|
+
console.log("Previous stack is still being deleted, waiting...");
|
|
56695
|
+
await cf.waitForStack(stackName, "stack-delete-complete");
|
|
56696
|
+
stackExists = false;
|
|
56697
|
+
} else if (stackStatus === "DELETE_COMPLETE") {
|
|
56698
|
+
stackExists = false;
|
|
56699
|
+
} else {
|
|
56700
|
+
stackExists = true;
|
|
56701
|
+
const outputs2 = stack.Outputs || [];
|
|
56702
|
+
existingBucketName = outputs2.find((o) => o.OutputKey === "BucketName")?.OutputValue;
|
|
56703
|
+
}
|
|
56704
|
+
}
|
|
56705
|
+
} catch (err) {
|
|
56706
|
+
if (err.message?.includes("does not exist") || err.code === "ValidationError") {
|
|
56707
|
+
stackExists = false;
|
|
56708
|
+
} else {
|
|
56709
|
+
throw err;
|
|
56710
|
+
}
|
|
56711
|
+
}
|
|
56712
|
+
let finalBucket = existingBucketName || bucket;
|
|
56713
|
+
if (!stackExists) {
|
|
56714
|
+
const s32 = new S3Client2(region);
|
|
56715
|
+
const cloudfront2 = new CloudFrontClient;
|
|
56108
56716
|
let hasExistingDistribution = false;
|
|
56109
56717
|
if (domain) {
|
|
56110
56718
|
try {
|
|
@@ -57423,6 +58031,9 @@ function colorize(text, color) {
|
|
|
57423
58031
|
function success(message) {
|
|
57424
58032
|
console.log(`${colors.green}✓${colors.reset} ${message}`);
|
|
57425
58033
|
}
|
|
58034
|
+
function error(message) {
|
|
58035
|
+
console.error(`${colors.red}✗${colors.reset} ${message}`);
|
|
58036
|
+
}
|
|
57426
58037
|
function warn(message) {
|
|
57427
58038
|
console.warn(`${colors.yellow}⚠${colors.reset} ${message}`);
|
|
57428
58039
|
}
|
|
@@ -73620,6 +74231,38 @@ class LambdaClient {
|
|
|
73620
74231
|
});
|
|
73621
74232
|
return result;
|
|
73622
74233
|
}
|
|
74234
|
+
async updateAlias(params) {
|
|
74235
|
+
const { FunctionName, Name, ...rest } = params;
|
|
74236
|
+
return this.client.request({
|
|
74237
|
+
service: "lambda",
|
|
74238
|
+
region: this.region,
|
|
74239
|
+
method: "PUT",
|
|
74240
|
+
path: `/2015-03-31/functions/${encodeURIComponent(FunctionName)}/aliases/${encodeURIComponent(Name)}`,
|
|
74241
|
+
headers: { "Content-Type": "application/json" },
|
|
74242
|
+
body: JSON.stringify(rest)
|
|
74243
|
+
});
|
|
74244
|
+
}
|
|
74245
|
+
async putProvisionedConcurrencyConfig(params) {
|
|
74246
|
+
const { FunctionName, Qualifier, ProvisionedConcurrentExecutions } = params;
|
|
74247
|
+
return this.client.request({
|
|
74248
|
+
service: "lambda",
|
|
74249
|
+
region: this.region,
|
|
74250
|
+
method: "PUT",
|
|
74251
|
+
path: `/2019-09-30/functions/${encodeURIComponent(FunctionName)}/provisioned-concurrency`,
|
|
74252
|
+
queryParams: { Qualifier },
|
|
74253
|
+
headers: { "Content-Type": "application/json" },
|
|
74254
|
+
body: JSON.stringify({ ProvisionedConcurrentExecutions })
|
|
74255
|
+
});
|
|
74256
|
+
}
|
|
74257
|
+
async deleteProvisionedConcurrencyConfig(functionName, qualifier) {
|
|
74258
|
+
await this.client.request({
|
|
74259
|
+
service: "lambda",
|
|
74260
|
+
region: this.region,
|
|
74261
|
+
method: "DELETE",
|
|
74262
|
+
path: `/2019-09-30/functions/${encodeURIComponent(functionName)}/provisioned-concurrency`,
|
|
74263
|
+
queryParams: { Qualifier: qualifier }
|
|
74264
|
+
});
|
|
74265
|
+
}
|
|
73623
74266
|
async waitForFunctionActive(functionName, maxWaitSeconds = 60) {
|
|
73624
74267
|
const startTime = Date.now();
|
|
73625
74268
|
const maxWaitMs = maxWaitSeconds * 1000;
|
|
@@ -73743,1860 +74386,1326 @@ class LambdaClient {
|
|
|
73743
74386
|
if (params?.Marker)
|
|
73744
74387
|
queryParams.Marker = params.Marker;
|
|
73745
74388
|
const result = await this.client.request({
|
|
73746
|
-
service: "lambda",
|
|
73747
|
-
region: this.region,
|
|
73748
|
-
method: "GET",
|
|
73749
|
-
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions`,
|
|
73750
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
73751
|
-
headers: {
|
|
73752
|
-
"Content-Type": "application/json"
|
|
73753
|
-
}
|
|
73754
|
-
});
|
|
73755
|
-
return result;
|
|
73756
|
-
}
|
|
73757
|
-
async getLayerVersion(layerName, versionNumber) {
|
|
73758
|
-
const result = await this.client.request({
|
|
73759
|
-
service: "lambda",
|
|
73760
|
-
region: this.region,
|
|
73761
|
-
method: "GET",
|
|
73762
|
-
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
|
|
73763
|
-
headers: {
|
|
73764
|
-
"Content-Type": "application/json"
|
|
73765
|
-
}
|
|
73766
|
-
});
|
|
73767
|
-
return result;
|
|
73768
|
-
}
|
|
73769
|
-
async addLayerVersionPermission(params) {
|
|
73770
|
-
const { LayerName, VersionNumber, ...rest } = params;
|
|
73771
|
-
const result = await this.client.request({
|
|
73772
|
-
service: "lambda",
|
|
73773
|
-
region: this.region,
|
|
73774
|
-
method: "POST",
|
|
73775
|
-
path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
|
|
73776
|
-
headers: {
|
|
73777
|
-
"Content-Type": "application/json"
|
|
73778
|
-
},
|
|
73779
|
-
body: JSON.stringify(rest)
|
|
73780
|
-
});
|
|
73781
|
-
return result;
|
|
73782
|
-
}
|
|
73783
|
-
async deleteLayerVersion(layerName, versionNumber) {
|
|
73784
|
-
await this.client.request({
|
|
73785
|
-
service: "lambda",
|
|
73786
|
-
region: this.region,
|
|
73787
|
-
method: "DELETE",
|
|
73788
|
-
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
|
|
73789
|
-
headers: {
|
|
73790
|
-
"Content-Type": "application/json"
|
|
73791
|
-
}
|
|
73792
|
-
});
|
|
73793
|
-
}
|
|
73794
|
-
}
|
|
73795
|
-
// src/aws/cloudwatch-logs.ts
|
|
73796
|
-
init_client();
|
|
73797
|
-
|
|
73798
|
-
class CloudWatchLogsClient {
|
|
73799
|
-
client;
|
|
73800
|
-
region;
|
|
73801
|
-
constructor(region = "us-east-1", profile) {
|
|
73802
|
-
this.region = region;
|
|
73803
|
-
this.client = new AWSClient;
|
|
73804
|
-
}
|
|
73805
|
-
async describeLogStreams(options) {
|
|
73806
|
-
const params = {
|
|
73807
|
-
logGroupName: options.logGroupName
|
|
73808
|
-
};
|
|
73809
|
-
if (options.logStreamNamePrefix)
|
|
73810
|
-
params.logStreamNamePrefix = options.logStreamNamePrefix;
|
|
73811
|
-
if (options.orderBy)
|
|
73812
|
-
params.orderBy = options.orderBy;
|
|
73813
|
-
if (options.descending !== undefined)
|
|
73814
|
-
params.descending = options.descending;
|
|
73815
|
-
if (options.limit)
|
|
73816
|
-
params.limit = options.limit;
|
|
73817
|
-
const result = await this.client.request({
|
|
73818
|
-
service: "logs",
|
|
73819
|
-
region: this.region,
|
|
73820
|
-
method: "POST",
|
|
73821
|
-
path: "/",
|
|
73822
|
-
headers: {
|
|
73823
|
-
"X-Amz-Target": "Logs_20140328.DescribeLogStreams",
|
|
73824
|
-
"Content-Type": "application/x-amz-json-1.1"
|
|
73825
|
-
},
|
|
73826
|
-
body: JSON.stringify(params)
|
|
73827
|
-
});
|
|
73828
|
-
return result;
|
|
73829
|
-
}
|
|
73830
|
-
async getLogEvents(options) {
|
|
73831
|
-
const params = {
|
|
73832
|
-
logGroupName: options.logGroupName,
|
|
73833
|
-
logStreamName: options.logStreamName
|
|
73834
|
-
};
|
|
73835
|
-
if (options.startTime)
|
|
73836
|
-
params.startTime = options.startTime;
|
|
73837
|
-
if (options.endTime)
|
|
73838
|
-
params.endTime = options.endTime;
|
|
73839
|
-
if (options.limit)
|
|
73840
|
-
params.limit = options.limit;
|
|
73841
|
-
if (options.startFromHead !== undefined)
|
|
73842
|
-
params.startFromHead = options.startFromHead;
|
|
73843
|
-
const result = await this.client.request({
|
|
73844
|
-
service: "logs",
|
|
73845
|
-
region: this.region,
|
|
73846
|
-
method: "POST",
|
|
73847
|
-
path: "/",
|
|
73848
|
-
headers: {
|
|
73849
|
-
"X-Amz-Target": "Logs_20140328.GetLogEvents",
|
|
73850
|
-
"Content-Type": "application/x-amz-json-1.1"
|
|
73851
|
-
},
|
|
73852
|
-
body: JSON.stringify(params)
|
|
73853
|
-
});
|
|
73854
|
-
return result;
|
|
73855
|
-
}
|
|
73856
|
-
async describeLogGroups(options) {
|
|
73857
|
-
const params = {};
|
|
73858
|
-
if (options?.logGroupNamePrefix)
|
|
73859
|
-
params.logGroupNamePrefix = options.logGroupNamePrefix;
|
|
73860
|
-
if (options?.limit)
|
|
73861
|
-
params.limit = options.limit;
|
|
73862
|
-
const result = await this.client.request({
|
|
73863
|
-
service: "logs",
|
|
73864
|
-
region: this.region,
|
|
73865
|
-
method: "POST",
|
|
73866
|
-
path: "/",
|
|
73867
|
-
headers: {
|
|
73868
|
-
"X-Amz-Target": "Logs_20140328.DescribeLogGroups",
|
|
73869
|
-
"Content-Type": "application/x-amz-json-1.1"
|
|
73870
|
-
},
|
|
73871
|
-
body: JSON.stringify(params)
|
|
73872
|
-
});
|
|
73873
|
-
return result;
|
|
73874
|
-
}
|
|
73875
|
-
async deleteLogGroup(logGroupName) {
|
|
73876
|
-
await this.client.request({
|
|
73877
|
-
service: "logs",
|
|
73878
|
-
region: this.region,
|
|
73879
|
-
method: "POST",
|
|
73880
|
-
path: "/",
|
|
73881
|
-
headers: {
|
|
73882
|
-
"X-Amz-Target": "Logs_20140328.DeleteLogGroup",
|
|
73883
|
-
"Content-Type": "application/x-amz-json-1.1"
|
|
73884
|
-
},
|
|
73885
|
-
body: JSON.stringify({ logGroupName })
|
|
73886
|
-
});
|
|
73887
|
-
}
|
|
73888
|
-
async filterLogEvents(options) {
|
|
73889
|
-
const params = {
|
|
73890
|
-
logGroupName: options.logGroupName
|
|
73891
|
-
};
|
|
73892
|
-
if (options.logStreamNames)
|
|
73893
|
-
params.logStreamNames = options.logStreamNames;
|
|
73894
|
-
if (options.startTime)
|
|
73895
|
-
params.startTime = options.startTime;
|
|
73896
|
-
if (options.endTime)
|
|
73897
|
-
params.endTime = options.endTime;
|
|
73898
|
-
if (options.filterPattern)
|
|
73899
|
-
params.filterPattern = options.filterPattern;
|
|
73900
|
-
if (options.limit)
|
|
73901
|
-
params.limit = options.limit;
|
|
73902
|
-
const result = await this.client.request({
|
|
73903
|
-
service: "logs",
|
|
73904
|
-
region: this.region,
|
|
73905
|
-
method: "POST",
|
|
73906
|
-
path: "/",
|
|
73907
|
-
headers: {
|
|
73908
|
-
"X-Amz-Target": "Logs_20140328.FilterLogEvents",
|
|
73909
|
-
"Content-Type": "application/x-amz-json-1.1"
|
|
73910
|
-
},
|
|
73911
|
-
body: JSON.stringify(params)
|
|
73912
|
-
});
|
|
73913
|
-
return result;
|
|
73914
|
-
}
|
|
73915
|
-
}
|
|
73916
|
-
// src/aws/connect.ts
|
|
73917
|
-
init_client();
|
|
73918
|
-
|
|
73919
|
-
class ConnectClient {
|
|
73920
|
-
client;
|
|
73921
|
-
region;
|
|
73922
|
-
constructor(region = "us-east-1") {
|
|
73923
|
-
this.region = region;
|
|
73924
|
-
this.client = new AWSClient;
|
|
73925
|
-
}
|
|
73926
|
-
async createInstance(params) {
|
|
73927
|
-
const body = {
|
|
73928
|
-
InstanceAlias: params.InstanceAlias,
|
|
73929
|
-
IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
|
|
73930
|
-
InboundCallsEnabled: params.InboundCallsEnabled ?? true,
|
|
73931
|
-
OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
|
|
73932
|
-
};
|
|
73933
|
-
if (params.DirectoryId)
|
|
73934
|
-
body.DirectoryId = params.DirectoryId;
|
|
73935
|
-
if (params.ClientToken)
|
|
73936
|
-
body.ClientToken = params.ClientToken;
|
|
73937
|
-
if (params.Tags)
|
|
73938
|
-
body.Tags = params.Tags;
|
|
73939
|
-
const result = await this.client.request({
|
|
73940
|
-
service: "connect",
|
|
73941
|
-
region: this.region,
|
|
73942
|
-
method: "PUT",
|
|
73943
|
-
path: "/instance",
|
|
73944
|
-
headers: {
|
|
73945
|
-
"Content-Type": "application/json"
|
|
73946
|
-
},
|
|
73947
|
-
body: JSON.stringify(body)
|
|
73948
|
-
});
|
|
73949
|
-
return result;
|
|
73950
|
-
}
|
|
73951
|
-
async deleteInstance(instanceId) {
|
|
73952
|
-
await this.client.request({
|
|
73953
|
-
service: "connect",
|
|
73954
|
-
region: this.region,
|
|
73955
|
-
method: "DELETE",
|
|
73956
|
-
path: `/instance/${instanceId}`
|
|
73957
|
-
});
|
|
73958
|
-
}
|
|
73959
|
-
async describeInstance(instanceId) {
|
|
73960
|
-
const result = await this.client.request({
|
|
73961
|
-
service: "connect",
|
|
73962
|
-
region: this.region,
|
|
73963
|
-
method: "GET",
|
|
73964
|
-
path: `/instance/${instanceId}`
|
|
73965
|
-
});
|
|
73966
|
-
return result.Instance || result;
|
|
73967
|
-
}
|
|
73968
|
-
async listInstances(params) {
|
|
73969
|
-
const queryParams = {};
|
|
73970
|
-
if (params?.MaxResults)
|
|
73971
|
-
queryParams.maxResults = String(params.MaxResults);
|
|
73972
|
-
if (params?.NextToken)
|
|
73973
|
-
queryParams.nextToken = params.NextToken;
|
|
73974
|
-
const result = await this.client.request({
|
|
73975
|
-
service: "connect",
|
|
73976
|
-
region: this.region,
|
|
73977
|
-
method: "GET",
|
|
73978
|
-
path: "/instance",
|
|
73979
|
-
queryParams
|
|
73980
|
-
});
|
|
73981
|
-
return result;
|
|
73982
|
-
}
|
|
73983
|
-
async searchAvailablePhoneNumbers(params) {
|
|
73984
|
-
const body = {
|
|
73985
|
-
TargetArn: params.TargetArn,
|
|
73986
|
-
PhoneNumberCountryCode: params.PhoneNumberCountryCode,
|
|
73987
|
-
PhoneNumberType: params.PhoneNumberType
|
|
73988
|
-
};
|
|
73989
|
-
if (params.PhoneNumberPrefix)
|
|
73990
|
-
body.PhoneNumberPrefix = params.PhoneNumberPrefix;
|
|
73991
|
-
if (params.MaxResults)
|
|
73992
|
-
body.MaxResults = params.MaxResults;
|
|
73993
|
-
if (params.NextToken)
|
|
73994
|
-
body.NextToken = params.NextToken;
|
|
73995
|
-
const result = await this.client.request({
|
|
73996
|
-
service: "connect",
|
|
73997
|
-
region: this.region,
|
|
73998
|
-
method: "POST",
|
|
73999
|
-
path: "/phone-number/search-available",
|
|
74000
|
-
headers: {
|
|
74001
|
-
"Content-Type": "application/json"
|
|
74002
|
-
},
|
|
74003
|
-
body: JSON.stringify(body)
|
|
74004
|
-
});
|
|
74005
|
-
return result;
|
|
74006
|
-
}
|
|
74007
|
-
async claimPhoneNumber(params) {
|
|
74008
|
-
const body = {
|
|
74009
|
-
TargetArn: params.TargetArn,
|
|
74010
|
-
PhoneNumber: params.PhoneNumber
|
|
74011
|
-
};
|
|
74012
|
-
if (params.PhoneNumberDescription)
|
|
74013
|
-
body.PhoneNumberDescription = params.PhoneNumberDescription;
|
|
74014
|
-
if (params.Tags)
|
|
74015
|
-
body.Tags = params.Tags;
|
|
74016
|
-
if (params.ClientToken)
|
|
74017
|
-
body.ClientToken = params.ClientToken;
|
|
74018
|
-
const result = await this.client.request({
|
|
74019
|
-
service: "connect",
|
|
74020
|
-
region: this.region,
|
|
74021
|
-
method: "POST",
|
|
74022
|
-
path: "/phone-number/claim",
|
|
74023
|
-
headers: {
|
|
74024
|
-
"Content-Type": "application/json"
|
|
74025
|
-
},
|
|
74026
|
-
body: JSON.stringify(body)
|
|
74027
|
-
});
|
|
74028
|
-
return result;
|
|
74029
|
-
}
|
|
74030
|
-
async releasePhoneNumber(phoneNumberId, clientToken) {
|
|
74031
|
-
const queryParams = {};
|
|
74032
|
-
if (clientToken)
|
|
74033
|
-
queryParams.clientToken = clientToken;
|
|
74034
|
-
await this.client.request({
|
|
74035
|
-
service: "connect",
|
|
74036
|
-
region: this.region,
|
|
74037
|
-
method: "DELETE",
|
|
74038
|
-
path: `/phone-number/${phoneNumberId}`,
|
|
74039
|
-
queryParams
|
|
74040
|
-
});
|
|
74041
|
-
}
|
|
74042
|
-
async listPhoneNumbers(params) {
|
|
74043
|
-
const body = {};
|
|
74044
|
-
if (params.TargetArn)
|
|
74045
|
-
body.TargetArn = params.TargetArn;
|
|
74046
|
-
if (params.InstanceId)
|
|
74047
|
-
body.InstanceId = params.InstanceId;
|
|
74048
|
-
if (params.PhoneNumberTypes)
|
|
74049
|
-
body.PhoneNumberTypes = params.PhoneNumberTypes;
|
|
74050
|
-
if (params.PhoneNumberCountryCodes)
|
|
74051
|
-
body.PhoneNumberCountryCodes = params.PhoneNumberCountryCodes;
|
|
74052
|
-
if (params.MaxResults)
|
|
74053
|
-
body.MaxResults = params.MaxResults;
|
|
74054
|
-
if (params.NextToken)
|
|
74055
|
-
body.NextToken = params.NextToken;
|
|
74056
|
-
const result = await this.client.request({
|
|
74057
|
-
service: "connect",
|
|
74058
|
-
region: this.region,
|
|
74059
|
-
method: "POST",
|
|
74060
|
-
path: "/phone-number/list",
|
|
74061
|
-
headers: {
|
|
74062
|
-
"Content-Type": "application/json"
|
|
74063
|
-
},
|
|
74064
|
-
body: JSON.stringify(body)
|
|
74065
|
-
});
|
|
74066
|
-
return result;
|
|
74067
|
-
}
|
|
74068
|
-
async createContactFlow(params) {
|
|
74069
|
-
const body = {
|
|
74070
|
-
Name: params.Name,
|
|
74071
|
-
Type: params.Type,
|
|
74072
|
-
Content: params.Content
|
|
74073
|
-
};
|
|
74074
|
-
if (params.Description)
|
|
74075
|
-
body.Description = params.Description;
|
|
74076
|
-
if (params.Tags)
|
|
74077
|
-
body.Tags = params.Tags;
|
|
74078
|
-
const result = await this.client.request({
|
|
74079
|
-
service: "connect",
|
|
74080
|
-
region: this.region,
|
|
74081
|
-
method: "PUT",
|
|
74082
|
-
path: `/contact-flows/${params.InstanceId}`,
|
|
74083
|
-
headers: {
|
|
74084
|
-
"Content-Type": "application/json"
|
|
74085
|
-
},
|
|
74086
|
-
body: JSON.stringify(body)
|
|
74087
|
-
});
|
|
74088
|
-
return result;
|
|
74089
|
-
}
|
|
74090
|
-
async updateContactFlowContent(params) {
|
|
74091
|
-
await this.client.request({
|
|
74092
|
-
service: "connect",
|
|
74093
|
-
region: this.region,
|
|
74094
|
-
method: "POST",
|
|
74095
|
-
path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
|
|
74096
|
-
headers: {
|
|
74097
|
-
"Content-Type": "application/json"
|
|
74098
|
-
},
|
|
74099
|
-
body: JSON.stringify({ Content: params.Content })
|
|
74100
|
-
});
|
|
74101
|
-
}
|
|
74102
|
-
async listContactFlows(params) {
|
|
74103
|
-
const queryParams = {};
|
|
74104
|
-
if (params.ContactFlowTypes)
|
|
74105
|
-
queryParams.contactFlowTypes = params.ContactFlowTypes.join(",");
|
|
74106
|
-
if (params.MaxResults)
|
|
74107
|
-
queryParams.maxResults = String(params.MaxResults);
|
|
74108
|
-
if (params.NextToken)
|
|
74109
|
-
queryParams.nextToken = params.NextToken;
|
|
74110
|
-
const result = await this.client.request({
|
|
74111
|
-
service: "connect",
|
|
74389
|
+
service: "lambda",
|
|
74112
74390
|
region: this.region,
|
|
74113
74391
|
method: "GET",
|
|
74114
|
-
path: `/
|
|
74115
|
-
queryParams
|
|
74392
|
+
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions`,
|
|
74393
|
+
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
74394
|
+
headers: {
|
|
74395
|
+
"Content-Type": "application/json"
|
|
74396
|
+
}
|
|
74116
74397
|
});
|
|
74117
74398
|
return result;
|
|
74118
74399
|
}
|
|
74119
|
-
async
|
|
74120
|
-
const body = {
|
|
74121
|
-
Name: params.Name,
|
|
74122
|
-
HoursOfOperationId: params.HoursOfOperationId
|
|
74123
|
-
};
|
|
74124
|
-
if (params.Description)
|
|
74125
|
-
body.Description = params.Description;
|
|
74126
|
-
if (params.MaxContacts)
|
|
74127
|
-
body.MaxContacts = params.MaxContacts;
|
|
74128
|
-
if (params.OutboundCallerConfig)
|
|
74129
|
-
body.OutboundCallerConfig = params.OutboundCallerConfig;
|
|
74130
|
-
if (params.Tags)
|
|
74131
|
-
body.Tags = params.Tags;
|
|
74400
|
+
async getLayerVersion(layerName, versionNumber) {
|
|
74132
74401
|
const result = await this.client.request({
|
|
74133
|
-
service: "
|
|
74402
|
+
service: "lambda",
|
|
74134
74403
|
region: this.region,
|
|
74135
|
-
method: "
|
|
74136
|
-
path: `/
|
|
74404
|
+
method: "GET",
|
|
74405
|
+
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
|
|
74137
74406
|
headers: {
|
|
74138
74407
|
"Content-Type": "application/json"
|
|
74139
|
-
}
|
|
74140
|
-
body: JSON.stringify(body)
|
|
74408
|
+
}
|
|
74141
74409
|
});
|
|
74142
74410
|
return result;
|
|
74143
74411
|
}
|
|
74144
|
-
async
|
|
74145
|
-
const
|
|
74146
|
-
Name: params.Name,
|
|
74147
|
-
TimeZone: params.TimeZone,
|
|
74148
|
-
Config: params.Config
|
|
74149
|
-
};
|
|
74150
|
-
if (params.Description)
|
|
74151
|
-
body.Description = params.Description;
|
|
74152
|
-
if (params.Tags)
|
|
74153
|
-
body.Tags = params.Tags;
|
|
74412
|
+
async addLayerVersionPermission(params) {
|
|
74413
|
+
const { LayerName, VersionNumber, ...rest } = params;
|
|
74154
74414
|
const result = await this.client.request({
|
|
74155
|
-
service: "
|
|
74415
|
+
service: "lambda",
|
|
74156
74416
|
region: this.region,
|
|
74157
|
-
method: "
|
|
74158
|
-
path: `/
|
|
74417
|
+
method: "POST",
|
|
74418
|
+
path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
|
|
74159
74419
|
headers: {
|
|
74160
74420
|
"Content-Type": "application/json"
|
|
74161
74421
|
},
|
|
74162
|
-
body: JSON.stringify(
|
|
74422
|
+
body: JSON.stringify(rest)
|
|
74163
74423
|
});
|
|
74164
74424
|
return result;
|
|
74165
74425
|
}
|
|
74166
|
-
async
|
|
74426
|
+
async deleteLayerVersion(layerName, versionNumber) {
|
|
74167
74427
|
await this.client.request({
|
|
74168
|
-
service: "
|
|
74428
|
+
service: "lambda",
|
|
74169
74429
|
region: this.region,
|
|
74170
|
-
method: "
|
|
74171
|
-
path: `/
|
|
74430
|
+
method: "DELETE",
|
|
74431
|
+
path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
|
|
74172
74432
|
headers: {
|
|
74173
74433
|
"Content-Type": "application/json"
|
|
74174
|
-
}
|
|
74175
|
-
body: JSON.stringify({
|
|
74176
|
-
InstanceId: params.InstanceId,
|
|
74177
|
-
ContactFlowId: params.ContactFlowId
|
|
74178
|
-
})
|
|
74434
|
+
}
|
|
74179
74435
|
});
|
|
74180
74436
|
}
|
|
74181
|
-
|
|
74182
|
-
|
|
74183
|
-
|
|
74184
|
-
|
|
74185
|
-
|
|
74437
|
+
}
|
|
74438
|
+
// src/aws/cloudwatch-logs.ts
|
|
74439
|
+
init_client();
|
|
74440
|
+
|
|
74441
|
+
class CloudWatchLogsClient {
|
|
74442
|
+
client;
|
|
74443
|
+
region;
|
|
74444
|
+
constructor(region = "us-east-1", profile) {
|
|
74445
|
+
this.region = region;
|
|
74446
|
+
this.client = new AWSClient;
|
|
74447
|
+
}
|
|
74448
|
+
async describeLogStreams(options) {
|
|
74449
|
+
const params = {
|
|
74450
|
+
logGroupName: options.logGroupName
|
|
74186
74451
|
};
|
|
74187
|
-
if (
|
|
74188
|
-
|
|
74189
|
-
if (
|
|
74190
|
-
|
|
74191
|
-
if (
|
|
74192
|
-
|
|
74452
|
+
if (options.logStreamNamePrefix)
|
|
74453
|
+
params.logStreamNamePrefix = options.logStreamNamePrefix;
|
|
74454
|
+
if (options.orderBy)
|
|
74455
|
+
params.orderBy = options.orderBy;
|
|
74456
|
+
if (options.descending !== undefined)
|
|
74457
|
+
params.descending = options.descending;
|
|
74458
|
+
if (options.limit)
|
|
74459
|
+
params.limit = options.limit;
|
|
74193
74460
|
const result = await this.client.request({
|
|
74194
|
-
service: "
|
|
74461
|
+
service: "logs",
|
|
74195
74462
|
region: this.region,
|
|
74196
|
-
method: "
|
|
74197
|
-
path:
|
|
74463
|
+
method: "POST",
|
|
74464
|
+
path: "/",
|
|
74198
74465
|
headers: {
|
|
74199
|
-
"
|
|
74466
|
+
"X-Amz-Target": "Logs_20140328.DescribeLogStreams",
|
|
74467
|
+
"Content-Type": "application/x-amz-json-1.1"
|
|
74200
74468
|
},
|
|
74201
|
-
body: JSON.stringify(
|
|
74469
|
+
body: JSON.stringify(params)
|
|
74202
74470
|
});
|
|
74203
74471
|
return result;
|
|
74204
74472
|
}
|
|
74205
|
-
async
|
|
74206
|
-
|
|
74207
|
-
|
|
74208
|
-
|
|
74209
|
-
} catch {
|
|
74210
|
-
return false;
|
|
74211
|
-
}
|
|
74212
|
-
}
|
|
74213
|
-
async startOutboundVoiceContact(params) {
|
|
74214
|
-
const body = {
|
|
74215
|
-
ContactFlowId: params.ContactFlowId,
|
|
74216
|
-
DestinationPhoneNumber: params.DestinationPhoneNumber
|
|
74473
|
+
async getLogEvents(options) {
|
|
74474
|
+
const params = {
|
|
74475
|
+
logGroupName: options.logGroupName,
|
|
74476
|
+
logStreamName: options.logStreamName
|
|
74217
74477
|
};
|
|
74218
|
-
if (
|
|
74219
|
-
|
|
74220
|
-
if (
|
|
74221
|
-
|
|
74222
|
-
if (
|
|
74223
|
-
|
|
74224
|
-
if (
|
|
74225
|
-
|
|
74226
|
-
if (params.CampaignId)
|
|
74227
|
-
body.CampaignId = params.CampaignId;
|
|
74228
|
-
if (params.TrafficType)
|
|
74229
|
-
body.TrafficType = params.TrafficType;
|
|
74230
|
-
if (params.ClientToken)
|
|
74231
|
-
body.ClientToken = params.ClientToken;
|
|
74478
|
+
if (options.startTime)
|
|
74479
|
+
params.startTime = options.startTime;
|
|
74480
|
+
if (options.endTime)
|
|
74481
|
+
params.endTime = options.endTime;
|
|
74482
|
+
if (options.limit)
|
|
74483
|
+
params.limit = options.limit;
|
|
74484
|
+
if (options.startFromHead !== undefined)
|
|
74485
|
+
params.startFromHead = options.startFromHead;
|
|
74232
74486
|
const result = await this.client.request({
|
|
74233
|
-
service: "
|
|
74487
|
+
service: "logs",
|
|
74234
74488
|
region: this.region,
|
|
74235
|
-
method: "
|
|
74236
|
-
path:
|
|
74489
|
+
method: "POST",
|
|
74490
|
+
path: "/",
|
|
74237
74491
|
headers: {
|
|
74238
|
-
"
|
|
74492
|
+
"X-Amz-Target": "Logs_20140328.GetLogEvents",
|
|
74493
|
+
"Content-Type": "application/x-amz-json-1.1"
|
|
74239
74494
|
},
|
|
74240
|
-
body: JSON.stringify(
|
|
74495
|
+
body: JSON.stringify(params)
|
|
74241
74496
|
});
|
|
74242
74497
|
return result;
|
|
74243
74498
|
}
|
|
74244
|
-
async
|
|
74245
|
-
|
|
74246
|
-
|
|
74247
|
-
|
|
74248
|
-
|
|
74249
|
-
|
|
74250
|
-
|
|
74251
|
-
|
|
74252
|
-
}
|
|
74253
|
-
async stopContact(params) {
|
|
74254
|
-
await this.client.request({
|
|
74255
|
-
service: "connect",
|
|
74499
|
+
async describeLogGroups(options) {
|
|
74500
|
+
const params = {};
|
|
74501
|
+
if (options?.logGroupNamePrefix)
|
|
74502
|
+
params.logGroupNamePrefix = options.logGroupNamePrefix;
|
|
74503
|
+
if (options?.limit)
|
|
74504
|
+
params.limit = options.limit;
|
|
74505
|
+
const result = await this.client.request({
|
|
74506
|
+
service: "logs",
|
|
74256
74507
|
region: this.region,
|
|
74257
74508
|
method: "POST",
|
|
74258
|
-
path:
|
|
74509
|
+
path: "/",
|
|
74510
|
+
headers: {
|
|
74511
|
+
"X-Amz-Target": "Logs_20140328.DescribeLogGroups",
|
|
74512
|
+
"Content-Type": "application/x-amz-json-1.1"
|
|
74513
|
+
},
|
|
74514
|
+
body: JSON.stringify(params)
|
|
74259
74515
|
});
|
|
74516
|
+
return result;
|
|
74260
74517
|
}
|
|
74261
|
-
async
|
|
74262
|
-
|
|
74263
|
-
service: "
|
|
74518
|
+
async deleteLogGroup(logGroupName) {
|
|
74519
|
+
await this.client.request({
|
|
74520
|
+
service: "logs",
|
|
74264
74521
|
region: this.region,
|
|
74265
|
-
method: "
|
|
74266
|
-
path:
|
|
74522
|
+
method: "POST",
|
|
74523
|
+
path: "/",
|
|
74524
|
+
headers: {
|
|
74525
|
+
"X-Amz-Target": "Logs_20140328.DeleteLogGroup",
|
|
74526
|
+
"Content-Type": "application/x-amz-json-1.1"
|
|
74527
|
+
},
|
|
74528
|
+
body: JSON.stringify({ logGroupName })
|
|
74267
74529
|
});
|
|
74268
74530
|
}
|
|
74269
|
-
async
|
|
74270
|
-
|
|
74271
|
-
|
|
74531
|
+
async filterLogEvents(options) {
|
|
74532
|
+
const params = {
|
|
74533
|
+
logGroupName: options.logGroupName
|
|
74534
|
+
};
|
|
74535
|
+
if (options.logStreamNames)
|
|
74536
|
+
params.logStreamNames = options.logStreamNames;
|
|
74537
|
+
if (options.startTime)
|
|
74538
|
+
params.startTime = options.startTime;
|
|
74539
|
+
if (options.endTime)
|
|
74540
|
+
params.endTime = options.endTime;
|
|
74541
|
+
if (options.filterPattern)
|
|
74542
|
+
params.filterPattern = options.filterPattern;
|
|
74543
|
+
if (options.limit)
|
|
74544
|
+
params.limit = options.limit;
|
|
74545
|
+
const result = await this.client.request({
|
|
74546
|
+
service: "logs",
|
|
74272
74547
|
region: this.region,
|
|
74273
74548
|
method: "POST",
|
|
74274
|
-
path:
|
|
74549
|
+
path: "/",
|
|
74275
74550
|
headers: {
|
|
74276
|
-
"
|
|
74551
|
+
"X-Amz-Target": "Logs_20140328.FilterLogEvents",
|
|
74552
|
+
"Content-Type": "application/x-amz-json-1.1"
|
|
74277
74553
|
},
|
|
74278
|
-
body: JSON.stringify(
|
|
74279
|
-
InitialContactId: params.InitialContactId,
|
|
74280
|
-
Attributes: params.Attributes
|
|
74281
|
-
})
|
|
74554
|
+
body: JSON.stringify(params)
|
|
74282
74555
|
});
|
|
74556
|
+
return result;
|
|
74283
74557
|
}
|
|
74284
|
-
|
|
74558
|
+
}
|
|
74559
|
+
// src/aws/connect.ts
|
|
74560
|
+
init_client();
|
|
74561
|
+
|
|
74562
|
+
class ConnectClient {
|
|
74563
|
+
client;
|
|
74564
|
+
region;
|
|
74565
|
+
constructor(region = "us-east-1") {
|
|
74566
|
+
this.region = region;
|
|
74567
|
+
this.client = new AWSClient;
|
|
74568
|
+
}
|
|
74569
|
+
async createInstance(params) {
|
|
74285
74570
|
const body = {
|
|
74286
|
-
|
|
74287
|
-
|
|
74288
|
-
|
|
74289
|
-
|
|
74571
|
+
InstanceAlias: params.InstanceAlias,
|
|
74572
|
+
IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
|
|
74573
|
+
InboundCallsEnabled: params.InboundCallsEnabled ?? true,
|
|
74574
|
+
OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
|
|
74290
74575
|
};
|
|
74291
|
-
if (params.
|
|
74292
|
-
body.
|
|
74293
|
-
if (params.
|
|
74294
|
-
body.
|
|
74295
|
-
if (params.DirectoryUserId)
|
|
74296
|
-
body.DirectoryUserId = params.DirectoryUserId;
|
|
74297
|
-
if (params.HierarchyGroupId)
|
|
74298
|
-
body.HierarchyGroupId = params.HierarchyGroupId;
|
|
74576
|
+
if (params.DirectoryId)
|
|
74577
|
+
body.DirectoryId = params.DirectoryId;
|
|
74578
|
+
if (params.ClientToken)
|
|
74579
|
+
body.ClientToken = params.ClientToken;
|
|
74299
74580
|
if (params.Tags)
|
|
74300
74581
|
body.Tags = params.Tags;
|
|
74301
|
-
|
|
74582
|
+
const result = await this.client.request({
|
|
74302
74583
|
service: "connect",
|
|
74303
74584
|
region: this.region,
|
|
74304
74585
|
method: "PUT",
|
|
74305
|
-
path:
|
|
74586
|
+
path: "/instance",
|
|
74306
74587
|
headers: {
|
|
74307
74588
|
"Content-Type": "application/json"
|
|
74308
74589
|
},
|
|
74309
74590
|
body: JSON.stringify(body)
|
|
74310
74591
|
});
|
|
74592
|
+
return result;
|
|
74311
74593
|
}
|
|
74312
|
-
async
|
|
74594
|
+
async deleteInstance(instanceId) {
|
|
74313
74595
|
await this.client.request({
|
|
74314
74596
|
service: "connect",
|
|
74315
74597
|
region: this.region,
|
|
74316
74598
|
method: "DELETE",
|
|
74317
|
-
path: `/
|
|
74599
|
+
path: `/instance/${instanceId}`
|
|
74318
74600
|
});
|
|
74319
74601
|
}
|
|
74320
|
-
async
|
|
74321
|
-
const
|
|
74322
|
-
if (params.NextToken)
|
|
74323
|
-
queryParams.nextToken = params.NextToken;
|
|
74324
|
-
if (params.MaxResults)
|
|
74325
|
-
queryParams.maxResults = String(params.MaxResults);
|
|
74326
|
-
return this.client.request({
|
|
74602
|
+
async describeInstance(instanceId) {
|
|
74603
|
+
const result = await this.client.request({
|
|
74327
74604
|
service: "connect",
|
|
74328
74605
|
region: this.region,
|
|
74329
74606
|
method: "GET",
|
|
74330
|
-
path: `/
|
|
74331
|
-
queryParams
|
|
74332
|
-
});
|
|
74333
|
-
}
|
|
74334
|
-
async createPrompt(params) {
|
|
74335
|
-
const body = {
|
|
74336
|
-
Name: params.Name,
|
|
74337
|
-
S3Uri: params.S3Uri
|
|
74338
|
-
};
|
|
74339
|
-
if (params.Description)
|
|
74340
|
-
body.Description = params.Description;
|
|
74341
|
-
if (params.Tags)
|
|
74342
|
-
body.Tags = params.Tags;
|
|
74343
|
-
return this.client.request({
|
|
74344
|
-
service: "connect",
|
|
74345
|
-
region: this.region,
|
|
74346
|
-
method: "PUT",
|
|
74347
|
-
path: `/prompts/${params.InstanceId}`,
|
|
74348
|
-
headers: {
|
|
74349
|
-
"Content-Type": "application/json"
|
|
74350
|
-
},
|
|
74351
|
-
body: JSON.stringify(body)
|
|
74607
|
+
path: `/instance/${instanceId}`
|
|
74352
74608
|
});
|
|
74609
|
+
return result.Instance || result;
|
|
74353
74610
|
}
|
|
74354
|
-
async
|
|
74611
|
+
async listInstances(params) {
|
|
74355
74612
|
const queryParams = {};
|
|
74356
|
-
if (params
|
|
74357
|
-
queryParams.nextToken = params.NextToken;
|
|
74358
|
-
if (params.MaxResults)
|
|
74613
|
+
if (params?.MaxResults)
|
|
74359
74614
|
queryParams.maxResults = String(params.MaxResults);
|
|
74360
|
-
|
|
74615
|
+
if (params?.NextToken)
|
|
74616
|
+
queryParams.nextToken = params.NextToken;
|
|
74617
|
+
const result = await this.client.request({
|
|
74361
74618
|
service: "connect",
|
|
74362
74619
|
region: this.region,
|
|
74363
74620
|
method: "GET",
|
|
74364
|
-
path:
|
|
74621
|
+
path: "/instance",
|
|
74365
74622
|
queryParams
|
|
74366
74623
|
});
|
|
74624
|
+
return result;
|
|
74367
74625
|
}
|
|
74368
|
-
async
|
|
74626
|
+
async searchAvailablePhoneNumbers(params) {
|
|
74369
74627
|
const body = {
|
|
74370
|
-
|
|
74371
|
-
|
|
74628
|
+
TargetArn: params.TargetArn,
|
|
74629
|
+
PhoneNumberCountryCode: params.PhoneNumberCountryCode,
|
|
74630
|
+
PhoneNumberType: params.PhoneNumberType
|
|
74372
74631
|
};
|
|
74373
|
-
if (params.
|
|
74374
|
-
body.
|
|
74375
|
-
if (params.
|
|
74376
|
-
body.
|
|
74377
|
-
|
|
74378
|
-
|
|
74379
|
-
region: this.region,
|
|
74380
|
-
method: "PUT",
|
|
74381
|
-
path: `/quick-connects/${params.InstanceId}`,
|
|
74382
|
-
headers: {
|
|
74383
|
-
"Content-Type": "application/json"
|
|
74384
|
-
},
|
|
74385
|
-
body: JSON.stringify(body)
|
|
74386
|
-
});
|
|
74387
|
-
}
|
|
74388
|
-
async startChatContact(params) {
|
|
74389
|
-
return this.client.request({
|
|
74390
|
-
service: "connect",
|
|
74391
|
-
region: this.region,
|
|
74392
|
-
method: "PUT",
|
|
74393
|
-
path: `/contact/chat/${params.InstanceId}`,
|
|
74394
|
-
headers: {
|
|
74395
|
-
"Content-Type": "application/json"
|
|
74396
|
-
},
|
|
74397
|
-
body: JSON.stringify(params)
|
|
74398
|
-
});
|
|
74399
|
-
}
|
|
74400
|
-
async startTaskContact(params) {
|
|
74401
|
-
return this.client.request({
|
|
74402
|
-
service: "connect",
|
|
74403
|
-
region: this.region,
|
|
74404
|
-
method: "PUT",
|
|
74405
|
-
path: `/contact/task/${params.InstanceId}`,
|
|
74406
|
-
headers: {
|
|
74407
|
-
"Content-Type": "application/json"
|
|
74408
|
-
},
|
|
74409
|
-
body: JSON.stringify(params)
|
|
74410
|
-
});
|
|
74411
|
-
}
|
|
74412
|
-
createOutboundIvrFlow(params) {
|
|
74413
|
-
const voiceId = params.voiceId || "Joanna";
|
|
74414
|
-
return JSON.stringify({
|
|
74415
|
-
Version: "2019-10-30",
|
|
74416
|
-
StartAction: "play-prompt",
|
|
74417
|
-
Actions: {
|
|
74418
|
-
"play-prompt": {
|
|
74419
|
-
Type: "MessageParticipant",
|
|
74420
|
-
Parameters: {
|
|
74421
|
-
Text: params.message,
|
|
74422
|
-
TextToSpeechVoice: voiceId,
|
|
74423
|
-
TextToSpeechEngine: "neural"
|
|
74424
|
-
},
|
|
74425
|
-
Transitions: {
|
|
74426
|
-
NextAction: "disconnect",
|
|
74427
|
-
Errors: [
|
|
74428
|
-
{ NextAction: "disconnect", ErrorType: "NoMatchingError" }
|
|
74429
|
-
]
|
|
74430
|
-
}
|
|
74431
|
-
},
|
|
74432
|
-
disconnect: {
|
|
74433
|
-
Type: "DisconnectParticipant",
|
|
74434
|
-
Parameters: {},
|
|
74435
|
-
Transitions: {}
|
|
74436
|
-
}
|
|
74437
|
-
}
|
|
74438
|
-
});
|
|
74439
|
-
}
|
|
74440
|
-
createInputCollectionFlow(params) {
|
|
74441
|
-
const voiceId = params.voiceId || "Joanna";
|
|
74442
|
-
const timeout = params.inputTimeout || 5;
|
|
74443
|
-
const maxDigits = params.maxDigits || 1;
|
|
74444
|
-
return JSON.stringify({
|
|
74445
|
-
Version: "2019-10-30",
|
|
74446
|
-
StartAction: "get-input",
|
|
74447
|
-
Actions: {
|
|
74448
|
-
"get-input": {
|
|
74449
|
-
Type: "GetParticipantInput",
|
|
74450
|
-
Parameters: {
|
|
74451
|
-
Text: params.promptMessage,
|
|
74452
|
-
TextToSpeechVoice: voiceId,
|
|
74453
|
-
TextToSpeechEngine: "neural",
|
|
74454
|
-
InputTimeLimitSeconds: String(timeout),
|
|
74455
|
-
MaxDigits: maxDigits,
|
|
74456
|
-
EncryptEntry: false
|
|
74457
|
-
},
|
|
74458
|
-
Transitions: {
|
|
74459
|
-
NextAction: params.successNextAction || "disconnect",
|
|
74460
|
-
Conditions: [],
|
|
74461
|
-
Errors: [
|
|
74462
|
-
{ NextAction: "disconnect", ErrorType: "NoMatchingCondition" },
|
|
74463
|
-
{ NextAction: "disconnect", ErrorType: "NoMatchingError" }
|
|
74464
|
-
]
|
|
74465
|
-
}
|
|
74466
|
-
},
|
|
74467
|
-
disconnect: {
|
|
74468
|
-
Type: "DisconnectParticipant",
|
|
74469
|
-
Parameters: {},
|
|
74470
|
-
Transitions: {}
|
|
74471
|
-
}
|
|
74472
|
-
}
|
|
74473
|
-
});
|
|
74474
|
-
}
|
|
74475
|
-
async getCurrentMetricData(params) {
|
|
74476
|
-
return this.client.request({
|
|
74477
|
-
service: "connect",
|
|
74478
|
-
region: this.region,
|
|
74479
|
-
method: "POST",
|
|
74480
|
-
path: `/metrics/current/${params.InstanceId}`,
|
|
74481
|
-
headers: {
|
|
74482
|
-
"Content-Type": "application/json"
|
|
74483
|
-
},
|
|
74484
|
-
body: JSON.stringify(params)
|
|
74485
|
-
});
|
|
74486
|
-
}
|
|
74487
|
-
}
|
|
74488
|
-
// src/aws/elbv2.ts
|
|
74489
|
-
init_client();
|
|
74490
|
-
|
|
74491
|
-
class ELBv2Client {
|
|
74492
|
-
client;
|
|
74493
|
-
region;
|
|
74494
|
-
constructor(region = "us-east-1") {
|
|
74495
|
-
this.region = region;
|
|
74496
|
-
this.client = new AWSClient;
|
|
74497
|
-
}
|
|
74498
|
-
async describeLoadBalancers(options) {
|
|
74499
|
-
const params = {};
|
|
74500
|
-
if (options?.LoadBalancerArns) {
|
|
74501
|
-
options.LoadBalancerArns.forEach((arn, index) => {
|
|
74502
|
-
params[`LoadBalancerArns.member.${index + 1}`] = arn;
|
|
74503
|
-
});
|
|
74504
|
-
}
|
|
74505
|
-
if (options?.Names) {
|
|
74506
|
-
options.Names.forEach((name, index) => {
|
|
74507
|
-
params[`Names.member.${index + 1}`] = name;
|
|
74508
|
-
});
|
|
74509
|
-
}
|
|
74510
|
-
if (options?.Marker) {
|
|
74511
|
-
params.Marker = options.Marker;
|
|
74512
|
-
}
|
|
74513
|
-
if (options?.PageSize) {
|
|
74514
|
-
params.PageSize = options.PageSize;
|
|
74515
|
-
}
|
|
74516
|
-
const result = await this.client.request({
|
|
74517
|
-
service: "elasticloadbalancing",
|
|
74518
|
-
region: this.region,
|
|
74519
|
-
method: "POST",
|
|
74520
|
-
path: "/",
|
|
74521
|
-
headers: {
|
|
74522
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
74523
|
-
},
|
|
74524
|
-
body: this.buildFormBody("DescribeLoadBalancers", params)
|
|
74525
|
-
});
|
|
74526
|
-
return this.normalizeResult(result, "DescribeLoadBalancersResult");
|
|
74527
|
-
}
|
|
74528
|
-
async describeTargetGroups(options) {
|
|
74529
|
-
const params = {};
|
|
74530
|
-
if (options?.LoadBalancerArn) {
|
|
74531
|
-
params.LoadBalancerArn = options.LoadBalancerArn;
|
|
74532
|
-
}
|
|
74533
|
-
if (options?.TargetGroupArns) {
|
|
74534
|
-
options.TargetGroupArns.forEach((arn, index) => {
|
|
74535
|
-
params[`TargetGroupArns.member.${index + 1}`] = arn;
|
|
74536
|
-
});
|
|
74537
|
-
}
|
|
74538
|
-
if (options?.Names) {
|
|
74539
|
-
options.Names.forEach((name, index) => {
|
|
74540
|
-
params[`Names.member.${index + 1}`] = name;
|
|
74541
|
-
});
|
|
74542
|
-
}
|
|
74543
|
-
if (options?.Marker) {
|
|
74544
|
-
params.Marker = options.Marker;
|
|
74545
|
-
}
|
|
74546
|
-
if (options?.PageSize) {
|
|
74547
|
-
params.PageSize = options.PageSize;
|
|
74548
|
-
}
|
|
74632
|
+
if (params.PhoneNumberPrefix)
|
|
74633
|
+
body.PhoneNumberPrefix = params.PhoneNumberPrefix;
|
|
74634
|
+
if (params.MaxResults)
|
|
74635
|
+
body.MaxResults = params.MaxResults;
|
|
74636
|
+
if (params.NextToken)
|
|
74637
|
+
body.NextToken = params.NextToken;
|
|
74549
74638
|
const result = await this.client.request({
|
|
74550
|
-
service: "
|
|
74639
|
+
service: "connect",
|
|
74551
74640
|
region: this.region,
|
|
74552
74641
|
method: "POST",
|
|
74553
|
-
path: "/",
|
|
74642
|
+
path: "/phone-number/search-available",
|
|
74554
74643
|
headers: {
|
|
74555
|
-
"Content-Type": "application/
|
|
74644
|
+
"Content-Type": "application/json"
|
|
74556
74645
|
},
|
|
74557
|
-
body:
|
|
74646
|
+
body: JSON.stringify(body)
|
|
74558
74647
|
});
|
|
74559
|
-
return
|
|
74648
|
+
return result;
|
|
74560
74649
|
}
|
|
74561
|
-
async
|
|
74562
|
-
const
|
|
74563
|
-
|
|
74650
|
+
async claimPhoneNumber(params) {
|
|
74651
|
+
const body = {
|
|
74652
|
+
TargetArn: params.TargetArn,
|
|
74653
|
+
PhoneNumber: params.PhoneNumber
|
|
74564
74654
|
};
|
|
74565
|
-
if (
|
|
74566
|
-
|
|
74567
|
-
|
|
74568
|
-
|
|
74569
|
-
|
|
74570
|
-
|
|
74571
|
-
if (target.AvailabilityZone) {
|
|
74572
|
-
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
74573
|
-
}
|
|
74574
|
-
});
|
|
74575
|
-
}
|
|
74655
|
+
if (params.PhoneNumberDescription)
|
|
74656
|
+
body.PhoneNumberDescription = params.PhoneNumberDescription;
|
|
74657
|
+
if (params.Tags)
|
|
74658
|
+
body.Tags = params.Tags;
|
|
74659
|
+
if (params.ClientToken)
|
|
74660
|
+
body.ClientToken = params.ClientToken;
|
|
74576
74661
|
const result = await this.client.request({
|
|
74577
|
-
service: "
|
|
74662
|
+
service: "connect",
|
|
74578
74663
|
region: this.region,
|
|
74579
74664
|
method: "POST",
|
|
74580
|
-
path: "/",
|
|
74665
|
+
path: "/phone-number/claim",
|
|
74581
74666
|
headers: {
|
|
74582
|
-
"Content-Type": "application/
|
|
74667
|
+
"Content-Type": "application/json"
|
|
74583
74668
|
},
|
|
74584
|
-
body:
|
|
74669
|
+
body: JSON.stringify(body)
|
|
74585
74670
|
});
|
|
74586
|
-
return
|
|
74671
|
+
return result;
|
|
74587
74672
|
}
|
|
74588
|
-
async
|
|
74589
|
-
const
|
|
74590
|
-
if (
|
|
74591
|
-
|
|
74592
|
-
|
|
74593
|
-
|
|
74594
|
-
|
|
74595
|
-
|
|
74596
|
-
}
|
|
74597
|
-
|
|
74598
|
-
|
|
74599
|
-
|
|
74600
|
-
|
|
74601
|
-
|
|
74602
|
-
|
|
74603
|
-
|
|
74673
|
+
async releasePhoneNumber(phoneNumberId, clientToken) {
|
|
74674
|
+
const queryParams = {};
|
|
74675
|
+
if (clientToken)
|
|
74676
|
+
queryParams.clientToken = clientToken;
|
|
74677
|
+
await this.client.request({
|
|
74678
|
+
service: "connect",
|
|
74679
|
+
region: this.region,
|
|
74680
|
+
method: "DELETE",
|
|
74681
|
+
path: `/phone-number/${phoneNumberId}`,
|
|
74682
|
+
queryParams
|
|
74683
|
+
});
|
|
74684
|
+
}
|
|
74685
|
+
async listPhoneNumbers(params) {
|
|
74686
|
+
const body = {};
|
|
74687
|
+
if (params.TargetArn)
|
|
74688
|
+
body.TargetArn = params.TargetArn;
|
|
74689
|
+
if (params.InstanceId)
|
|
74690
|
+
body.InstanceId = params.InstanceId;
|
|
74691
|
+
if (params.PhoneNumberTypes)
|
|
74692
|
+
body.PhoneNumberTypes = params.PhoneNumberTypes;
|
|
74693
|
+
if (params.PhoneNumberCountryCodes)
|
|
74694
|
+
body.PhoneNumberCountryCodes = params.PhoneNumberCountryCodes;
|
|
74695
|
+
if (params.MaxResults)
|
|
74696
|
+
body.MaxResults = params.MaxResults;
|
|
74697
|
+
if (params.NextToken)
|
|
74698
|
+
body.NextToken = params.NextToken;
|
|
74604
74699
|
const result = await this.client.request({
|
|
74605
|
-
service: "
|
|
74700
|
+
service: "connect",
|
|
74606
74701
|
region: this.region,
|
|
74607
74702
|
method: "POST",
|
|
74608
|
-
path: "/",
|
|
74703
|
+
path: "/phone-number/list",
|
|
74609
74704
|
headers: {
|
|
74610
|
-
"Content-Type": "application/
|
|
74705
|
+
"Content-Type": "application/json"
|
|
74611
74706
|
},
|
|
74612
|
-
body:
|
|
74707
|
+
body: JSON.stringify(body)
|
|
74613
74708
|
});
|
|
74614
|
-
return
|
|
74709
|
+
return result;
|
|
74615
74710
|
}
|
|
74616
|
-
async
|
|
74617
|
-
const
|
|
74618
|
-
|
|
74619
|
-
params.
|
|
74620
|
-
|
|
74621
|
-
|
|
74622
|
-
|
|
74623
|
-
|
|
74624
|
-
|
|
74625
|
-
|
|
74626
|
-
if (options?.Marker) {
|
|
74627
|
-
params.Marker = options.Marker;
|
|
74628
|
-
}
|
|
74629
|
-
if (options?.PageSize) {
|
|
74630
|
-
params.PageSize = options.PageSize;
|
|
74631
|
-
}
|
|
74711
|
+
async createContactFlow(params) {
|
|
74712
|
+
const body = {
|
|
74713
|
+
Name: params.Name,
|
|
74714
|
+
Type: params.Type,
|
|
74715
|
+
Content: params.Content
|
|
74716
|
+
};
|
|
74717
|
+
if (params.Description)
|
|
74718
|
+
body.Description = params.Description;
|
|
74719
|
+
if (params.Tags)
|
|
74720
|
+
body.Tags = params.Tags;
|
|
74632
74721
|
const result = await this.client.request({
|
|
74633
|
-
service: "
|
|
74722
|
+
service: "connect",
|
|
74634
74723
|
region: this.region,
|
|
74635
|
-
method: "
|
|
74636
|
-
path:
|
|
74724
|
+
method: "PUT",
|
|
74725
|
+
path: `/contact-flows/${params.InstanceId}`,
|
|
74637
74726
|
headers: {
|
|
74638
|
-
"Content-Type": "application/
|
|
74727
|
+
"Content-Type": "application/json"
|
|
74639
74728
|
},
|
|
74640
|
-
body:
|
|
74729
|
+
body: JSON.stringify(body)
|
|
74641
74730
|
});
|
|
74642
|
-
return
|
|
74731
|
+
return result;
|
|
74643
74732
|
}
|
|
74644
|
-
async
|
|
74645
|
-
|
|
74646
|
-
|
|
74647
|
-
};
|
|
74648
|
-
const result = await this.client.request({
|
|
74649
|
-
service: "elasticloadbalancing",
|
|
74733
|
+
async updateContactFlowContent(params) {
|
|
74734
|
+
await this.client.request({
|
|
74735
|
+
service: "connect",
|
|
74650
74736
|
region: this.region,
|
|
74651
74737
|
method: "POST",
|
|
74652
|
-
path:
|
|
74738
|
+
path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
|
|
74653
74739
|
headers: {
|
|
74654
|
-
"Content-Type": "application/
|
|
74740
|
+
"Content-Type": "application/json"
|
|
74655
74741
|
},
|
|
74656
|
-
body:
|
|
74742
|
+
body: JSON.stringify({ Content: params.Content })
|
|
74657
74743
|
});
|
|
74658
|
-
return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
|
|
74659
74744
|
}
|
|
74660
|
-
async
|
|
74661
|
-
const
|
|
74662
|
-
|
|
74745
|
+
async listContactFlows(params) {
|
|
74746
|
+
const queryParams = {};
|
|
74747
|
+
if (params.ContactFlowTypes)
|
|
74748
|
+
queryParams.contactFlowTypes = params.ContactFlowTypes.join(",");
|
|
74749
|
+
if (params.MaxResults)
|
|
74750
|
+
queryParams.maxResults = String(params.MaxResults);
|
|
74751
|
+
if (params.NextToken)
|
|
74752
|
+
queryParams.nextToken = params.NextToken;
|
|
74753
|
+
const result = await this.client.request({
|
|
74754
|
+
service: "connect",
|
|
74755
|
+
region: this.region,
|
|
74756
|
+
method: "GET",
|
|
74757
|
+
path: `/contact-flows-summary/${params.InstanceId}`,
|
|
74758
|
+
queryParams
|
|
74759
|
+
});
|
|
74760
|
+
return result;
|
|
74761
|
+
}
|
|
74762
|
+
async createQueue(params) {
|
|
74763
|
+
const body = {
|
|
74764
|
+
Name: params.Name,
|
|
74765
|
+
HoursOfOperationId: params.HoursOfOperationId
|
|
74663
74766
|
};
|
|
74767
|
+
if (params.Description)
|
|
74768
|
+
body.Description = params.Description;
|
|
74769
|
+
if (params.MaxContacts)
|
|
74770
|
+
body.MaxContacts = params.MaxContacts;
|
|
74771
|
+
if (params.OutboundCallerConfig)
|
|
74772
|
+
body.OutboundCallerConfig = params.OutboundCallerConfig;
|
|
74773
|
+
if (params.Tags)
|
|
74774
|
+
body.Tags = params.Tags;
|
|
74664
74775
|
const result = await this.client.request({
|
|
74665
|
-
service: "
|
|
74776
|
+
service: "connect",
|
|
74666
74777
|
region: this.region,
|
|
74667
|
-
method: "
|
|
74668
|
-
path:
|
|
74778
|
+
method: "PUT",
|
|
74779
|
+
path: `/queues/${params.InstanceId}`,
|
|
74669
74780
|
headers: {
|
|
74670
|
-
"Content-Type": "application/
|
|
74781
|
+
"Content-Type": "application/json"
|
|
74671
74782
|
},
|
|
74672
|
-
body:
|
|
74783
|
+
body: JSON.stringify(body)
|
|
74673
74784
|
});
|
|
74674
|
-
return
|
|
74785
|
+
return result;
|
|
74675
74786
|
}
|
|
74676
|
-
async
|
|
74677
|
-
const
|
|
74678
|
-
Name:
|
|
74787
|
+
async createHoursOfOperation(params) {
|
|
74788
|
+
const body = {
|
|
74789
|
+
Name: params.Name,
|
|
74790
|
+
TimeZone: params.TimeZone,
|
|
74791
|
+
Config: params.Config
|
|
74679
74792
|
};
|
|
74680
|
-
if (
|
|
74681
|
-
|
|
74682
|
-
|
|
74683
|
-
|
|
74684
|
-
}
|
|
74685
|
-
if (options.SubnetMappings) {
|
|
74686
|
-
options.SubnetMappings.forEach((mapping, index) => {
|
|
74687
|
-
params[`SubnetMappings.member.${index + 1}.SubnetId`] = mapping.SubnetId;
|
|
74688
|
-
if (mapping.AllocationId) {
|
|
74689
|
-
params[`SubnetMappings.member.${index + 1}.AllocationId`] = mapping.AllocationId;
|
|
74690
|
-
}
|
|
74691
|
-
if (mapping.PrivateIPv4Address) {
|
|
74692
|
-
params[`SubnetMappings.member.${index + 1}.PrivateIPv4Address`] = mapping.PrivateIPv4Address;
|
|
74693
|
-
}
|
|
74694
|
-
if (mapping.IPv6Address) {
|
|
74695
|
-
params[`SubnetMappings.member.${index + 1}.IPv6Address`] = mapping.IPv6Address;
|
|
74696
|
-
}
|
|
74697
|
-
});
|
|
74698
|
-
}
|
|
74699
|
-
if (options.SecurityGroups) {
|
|
74700
|
-
options.SecurityGroups.forEach((sg, index) => {
|
|
74701
|
-
params[`SecurityGroups.member.${index + 1}`] = sg;
|
|
74702
|
-
});
|
|
74703
|
-
}
|
|
74704
|
-
if (options.Scheme) {
|
|
74705
|
-
params.Scheme = options.Scheme;
|
|
74706
|
-
}
|
|
74707
|
-
if (options.Type) {
|
|
74708
|
-
params.Type = options.Type;
|
|
74709
|
-
}
|
|
74710
|
-
if (options.IpAddressType) {
|
|
74711
|
-
params.IpAddressType = options.IpAddressType;
|
|
74712
|
-
}
|
|
74713
|
-
if (options.Tags) {
|
|
74714
|
-
options.Tags.forEach((tag, index) => {
|
|
74715
|
-
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
74716
|
-
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
74717
|
-
});
|
|
74718
|
-
}
|
|
74793
|
+
if (params.Description)
|
|
74794
|
+
body.Description = params.Description;
|
|
74795
|
+
if (params.Tags)
|
|
74796
|
+
body.Tags = params.Tags;
|
|
74719
74797
|
const result = await this.client.request({
|
|
74720
|
-
service: "
|
|
74798
|
+
service: "connect",
|
|
74721
74799
|
region: this.region,
|
|
74722
|
-
method: "
|
|
74723
|
-
path:
|
|
74800
|
+
method: "PUT",
|
|
74801
|
+
path: `/hours-of-operations/${params.InstanceId}`,
|
|
74724
74802
|
headers: {
|
|
74725
|
-
"Content-Type": "application/
|
|
74803
|
+
"Content-Type": "application/json"
|
|
74726
74804
|
},
|
|
74727
|
-
body:
|
|
74805
|
+
body: JSON.stringify(body)
|
|
74728
74806
|
});
|
|
74729
|
-
return
|
|
74807
|
+
return result;
|
|
74730
74808
|
}
|
|
74731
|
-
async
|
|
74732
|
-
const params = {
|
|
74733
|
-
LoadBalancerArn: loadBalancerArn
|
|
74734
|
-
};
|
|
74809
|
+
async associatePhoneNumberContactFlow(params) {
|
|
74735
74810
|
await this.client.request({
|
|
74736
|
-
service: "
|
|
74811
|
+
service: "connect",
|
|
74737
74812
|
region: this.region,
|
|
74738
|
-
method: "
|
|
74739
|
-
path:
|
|
74813
|
+
method: "PUT",
|
|
74814
|
+
path: `/phone-number/${params.PhoneNumberId}/contact-flow`,
|
|
74740
74815
|
headers: {
|
|
74741
|
-
"Content-Type": "application/
|
|
74816
|
+
"Content-Type": "application/json"
|
|
74742
74817
|
},
|
|
74743
|
-
body:
|
|
74818
|
+
body: JSON.stringify({
|
|
74819
|
+
InstanceId: params.InstanceId,
|
|
74820
|
+
ContactFlowId: params.ContactFlowId
|
|
74821
|
+
})
|
|
74744
74822
|
});
|
|
74745
74823
|
}
|
|
74746
|
-
async
|
|
74747
|
-
const
|
|
74748
|
-
Name:
|
|
74824
|
+
async createRoutingProfile(params) {
|
|
74825
|
+
const body = {
|
|
74826
|
+
Name: params.Name,
|
|
74827
|
+
DefaultOutboundQueueId: params.DefaultOutboundQueueId,
|
|
74828
|
+
MediaConcurrencies: params.MediaConcurrencies
|
|
74749
74829
|
};
|
|
74750
|
-
if (
|
|
74751
|
-
|
|
74752
|
-
if (
|
|
74753
|
-
|
|
74754
|
-
if (
|
|
74755
|
-
|
|
74756
|
-
if (options.VpcId)
|
|
74757
|
-
params.VpcId = options.VpcId;
|
|
74758
|
-
if (options.HealthCheckProtocol)
|
|
74759
|
-
params.HealthCheckProtocol = options.HealthCheckProtocol;
|
|
74760
|
-
if (options.HealthCheckPort)
|
|
74761
|
-
params.HealthCheckPort = options.HealthCheckPort;
|
|
74762
|
-
if (options.HealthCheckEnabled !== undefined)
|
|
74763
|
-
params.HealthCheckEnabled = options.HealthCheckEnabled;
|
|
74764
|
-
if (options.HealthCheckPath)
|
|
74765
|
-
params.HealthCheckPath = options.HealthCheckPath;
|
|
74766
|
-
if (options.HealthCheckIntervalSeconds)
|
|
74767
|
-
params.HealthCheckIntervalSeconds = options.HealthCheckIntervalSeconds;
|
|
74768
|
-
if (options.HealthCheckTimeoutSeconds)
|
|
74769
|
-
params.HealthCheckTimeoutSeconds = options.HealthCheckTimeoutSeconds;
|
|
74770
|
-
if (options.HealthyThresholdCount)
|
|
74771
|
-
params.HealthyThresholdCount = options.HealthyThresholdCount;
|
|
74772
|
-
if (options.UnhealthyThresholdCount)
|
|
74773
|
-
params.UnhealthyThresholdCount = options.UnhealthyThresholdCount;
|
|
74774
|
-
if (options.TargetType)
|
|
74775
|
-
params.TargetType = options.TargetType;
|
|
74776
|
-
if (options.IpAddressType)
|
|
74777
|
-
params.IpAddressType = options.IpAddressType;
|
|
74778
|
-
if (options.Matcher) {
|
|
74779
|
-
if (options.Matcher.HttpCode)
|
|
74780
|
-
params["Matcher.HttpCode"] = options.Matcher.HttpCode;
|
|
74781
|
-
if (options.Matcher.GrpcCode)
|
|
74782
|
-
params["Matcher.GrpcCode"] = options.Matcher.GrpcCode;
|
|
74783
|
-
}
|
|
74784
|
-
if (options.Tags) {
|
|
74785
|
-
options.Tags.forEach((tag, index) => {
|
|
74786
|
-
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
74787
|
-
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
74788
|
-
});
|
|
74789
|
-
}
|
|
74830
|
+
if (params.Description)
|
|
74831
|
+
body.Description = params.Description;
|
|
74832
|
+
if (params.QueueConfigs)
|
|
74833
|
+
body.QueueConfigs = params.QueueConfigs;
|
|
74834
|
+
if (params.Tags)
|
|
74835
|
+
body.Tags = params.Tags;
|
|
74790
74836
|
const result = await this.client.request({
|
|
74791
|
-
service: "
|
|
74837
|
+
service: "connect",
|
|
74792
74838
|
region: this.region,
|
|
74793
|
-
method: "
|
|
74794
|
-
path:
|
|
74839
|
+
method: "PUT",
|
|
74840
|
+
path: `/routing-profiles/${params.InstanceId}`,
|
|
74795
74841
|
headers: {
|
|
74796
|
-
"Content-Type": "application/
|
|
74842
|
+
"Content-Type": "application/json"
|
|
74797
74843
|
},
|
|
74798
|
-
body:
|
|
74844
|
+
body: JSON.stringify(body)
|
|
74799
74845
|
});
|
|
74800
|
-
return
|
|
74846
|
+
return result;
|
|
74801
74847
|
}
|
|
74802
|
-
async
|
|
74803
|
-
|
|
74804
|
-
|
|
74848
|
+
async instanceExists(instanceAlias) {
|
|
74849
|
+
try {
|
|
74850
|
+
const result = await this.listInstances({ MaxResults: 100 });
|
|
74851
|
+
return result.InstanceSummaryList?.some((instance) => instance.InstanceAlias === instanceAlias) || false;
|
|
74852
|
+
} catch {
|
|
74853
|
+
return false;
|
|
74854
|
+
}
|
|
74855
|
+
}
|
|
74856
|
+
async startOutboundVoiceContact(params) {
|
|
74857
|
+
const body = {
|
|
74858
|
+
ContactFlowId: params.ContactFlowId,
|
|
74859
|
+
DestinationPhoneNumber: params.DestinationPhoneNumber
|
|
74805
74860
|
};
|
|
74806
|
-
|
|
74807
|
-
|
|
74861
|
+
if (params.SourcePhoneNumber)
|
|
74862
|
+
body.SourcePhoneNumber = params.SourcePhoneNumber;
|
|
74863
|
+
if (params.QueueId)
|
|
74864
|
+
body.QueueId = params.QueueId;
|
|
74865
|
+
if (params.Attributes)
|
|
74866
|
+
body.Attributes = params.Attributes;
|
|
74867
|
+
if (params.AnswerMachineDetectionConfig)
|
|
74868
|
+
body.AnswerMachineDetectionConfig = params.AnswerMachineDetectionConfig;
|
|
74869
|
+
if (params.CampaignId)
|
|
74870
|
+
body.CampaignId = params.CampaignId;
|
|
74871
|
+
if (params.TrafficType)
|
|
74872
|
+
body.TrafficType = params.TrafficType;
|
|
74873
|
+
if (params.ClientToken)
|
|
74874
|
+
body.ClientToken = params.ClientToken;
|
|
74875
|
+
const result = await this.client.request({
|
|
74876
|
+
service: "connect",
|
|
74808
74877
|
region: this.region,
|
|
74809
|
-
method: "
|
|
74810
|
-
path:
|
|
74878
|
+
method: "PUT",
|
|
74879
|
+
path: `/contact/outbound-voice/${params.InstanceId}`,
|
|
74811
74880
|
headers: {
|
|
74812
|
-
"Content-Type": "application/
|
|
74881
|
+
"Content-Type": "application/json"
|
|
74813
74882
|
},
|
|
74814
|
-
body:
|
|
74883
|
+
body: JSON.stringify(body)
|
|
74815
74884
|
});
|
|
74885
|
+
return result;
|
|
74816
74886
|
}
|
|
74817
|
-
async
|
|
74818
|
-
|
|
74819
|
-
|
|
74820
|
-
|
|
74821
|
-
|
|
74822
|
-
params
|
|
74823
|
-
|
|
74824
|
-
params[`Targets.member.${index + 1}.Port`] = target.Port;
|
|
74825
|
-
}
|
|
74826
|
-
if (target.AvailabilityZone) {
|
|
74827
|
-
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
74828
|
-
}
|
|
74887
|
+
async makeCall(params) {
|
|
74888
|
+
return this.startOutboundVoiceContact({
|
|
74889
|
+
InstanceId: params.instanceId,
|
|
74890
|
+
ContactFlowId: params.contactFlowId,
|
|
74891
|
+
DestinationPhoneNumber: params.to,
|
|
74892
|
+
SourcePhoneNumber: params.from,
|
|
74893
|
+
Attributes: params.attributes
|
|
74829
74894
|
});
|
|
74895
|
+
}
|
|
74896
|
+
async stopContact(params) {
|
|
74830
74897
|
await this.client.request({
|
|
74831
|
-
service: "
|
|
74898
|
+
service: "connect",
|
|
74832
74899
|
region: this.region,
|
|
74833
74900
|
method: "POST",
|
|
74834
|
-
path:
|
|
74835
|
-
headers: {
|
|
74836
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
74837
|
-
},
|
|
74838
|
-
body: this.buildFormBody("RegisterTargets", params)
|
|
74901
|
+
path: `/contact/stop/${params.InstanceId}/${params.ContactId}`
|
|
74839
74902
|
});
|
|
74840
74903
|
}
|
|
74841
|
-
async
|
|
74842
|
-
|
|
74843
|
-
|
|
74844
|
-
|
|
74845
|
-
|
|
74846
|
-
params
|
|
74847
|
-
if (target.Port) {
|
|
74848
|
-
params[`Targets.member.${index + 1}.Port`] = target.Port;
|
|
74849
|
-
}
|
|
74850
|
-
if (target.AvailabilityZone) {
|
|
74851
|
-
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
74852
|
-
}
|
|
74904
|
+
async describeContact(params) {
|
|
74905
|
+
return this.client.request({
|
|
74906
|
+
service: "connect",
|
|
74907
|
+
region: this.region,
|
|
74908
|
+
method: "GET",
|
|
74909
|
+
path: `/contacts/${params.InstanceId}/${params.ContactId}`
|
|
74853
74910
|
});
|
|
74911
|
+
}
|
|
74912
|
+
async updateContactAttributes(params) {
|
|
74854
74913
|
await this.client.request({
|
|
74855
|
-
service: "
|
|
74914
|
+
service: "connect",
|
|
74856
74915
|
region: this.region,
|
|
74857
74916
|
method: "POST",
|
|
74858
|
-
path:
|
|
74917
|
+
path: `/contact/attributes/${params.InstanceId}`,
|
|
74859
74918
|
headers: {
|
|
74860
|
-
"Content-Type": "application/
|
|
74919
|
+
"Content-Type": "application/json"
|
|
74861
74920
|
},
|
|
74862
|
-
body:
|
|
74921
|
+
body: JSON.stringify({
|
|
74922
|
+
InitialContactId: params.InitialContactId,
|
|
74923
|
+
Attributes: params.Attributes
|
|
74924
|
+
})
|
|
74863
74925
|
});
|
|
74864
74926
|
}
|
|
74865
|
-
async
|
|
74866
|
-
const
|
|
74867
|
-
|
|
74868
|
-
|
|
74927
|
+
async createUser(params) {
|
|
74928
|
+
const body = {
|
|
74929
|
+
Username: params.Username,
|
|
74930
|
+
PhoneConfig: params.PhoneConfig,
|
|
74931
|
+
SecurityProfileIds: params.SecurityProfileIds,
|
|
74932
|
+
RoutingProfileId: params.RoutingProfileId
|
|
74869
74933
|
};
|
|
74870
|
-
if (
|
|
74871
|
-
|
|
74872
|
-
if (
|
|
74873
|
-
|
|
74874
|
-
if (
|
|
74875
|
-
|
|
74876
|
-
|
|
74877
|
-
|
|
74878
|
-
|
|
74879
|
-
|
|
74880
|
-
|
|
74881
|
-
|
|
74882
|
-
params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
|
|
74883
|
-
}
|
|
74884
|
-
if (action.Order !== undefined) {
|
|
74885
|
-
params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
|
|
74886
|
-
}
|
|
74887
|
-
if (action.RedirectConfig) {
|
|
74888
|
-
const rc = action.RedirectConfig;
|
|
74889
|
-
if (rc.Protocol)
|
|
74890
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.Protocol`] = rc.Protocol;
|
|
74891
|
-
if (rc.Port)
|
|
74892
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.Port`] = rc.Port;
|
|
74893
|
-
if (rc.Host)
|
|
74894
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.Host`] = rc.Host;
|
|
74895
|
-
if (rc.Path)
|
|
74896
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.Path`] = rc.Path;
|
|
74897
|
-
if (rc.Query)
|
|
74898
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.Query`] = rc.Query;
|
|
74899
|
-
params[`DefaultActions.member.${index + 1}.RedirectConfig.StatusCode`] = rc.StatusCode;
|
|
74900
|
-
}
|
|
74901
|
-
if (action.FixedResponseConfig) {
|
|
74902
|
-
const fr = action.FixedResponseConfig;
|
|
74903
|
-
if (fr.MessageBody)
|
|
74904
|
-
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.MessageBody`] = fr.MessageBody;
|
|
74905
|
-
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.StatusCode`] = fr.StatusCode;
|
|
74906
|
-
if (fr.ContentType)
|
|
74907
|
-
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.ContentType`] = fr.ContentType;
|
|
74908
|
-
}
|
|
74909
|
-
});
|
|
74910
|
-
if (options.AlpnPolicy) {
|
|
74911
|
-
options.AlpnPolicy.forEach((policy, index) => {
|
|
74912
|
-
params[`AlpnPolicy.member.${index + 1}`] = policy;
|
|
74913
|
-
});
|
|
74914
|
-
}
|
|
74915
|
-
if (options.Tags) {
|
|
74916
|
-
options.Tags.forEach((tag, index) => {
|
|
74917
|
-
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
74918
|
-
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
74919
|
-
});
|
|
74920
|
-
}
|
|
74921
|
-
const result = await this.client.request({
|
|
74922
|
-
service: "elasticloadbalancing",
|
|
74934
|
+
if (params.Password)
|
|
74935
|
+
body.Password = params.Password;
|
|
74936
|
+
if (params.IdentityInfo)
|
|
74937
|
+
body.IdentityInfo = params.IdentityInfo;
|
|
74938
|
+
if (params.DirectoryUserId)
|
|
74939
|
+
body.DirectoryUserId = params.DirectoryUserId;
|
|
74940
|
+
if (params.HierarchyGroupId)
|
|
74941
|
+
body.HierarchyGroupId = params.HierarchyGroupId;
|
|
74942
|
+
if (params.Tags)
|
|
74943
|
+
body.Tags = params.Tags;
|
|
74944
|
+
return this.client.request({
|
|
74945
|
+
service: "connect",
|
|
74923
74946
|
region: this.region,
|
|
74924
|
-
method: "
|
|
74925
|
-
path:
|
|
74947
|
+
method: "PUT",
|
|
74948
|
+
path: `/users/${params.InstanceId}`,
|
|
74926
74949
|
headers: {
|
|
74927
|
-
"Content-Type": "application/
|
|
74950
|
+
"Content-Type": "application/json"
|
|
74928
74951
|
},
|
|
74929
|
-
body:
|
|
74952
|
+
body: JSON.stringify(body)
|
|
74930
74953
|
});
|
|
74931
|
-
return this.normalizeResult(result, "CreateListenerResult");
|
|
74932
74954
|
}
|
|
74933
|
-
async
|
|
74934
|
-
const params = {
|
|
74935
|
-
ListenerArn: listenerArn
|
|
74936
|
-
};
|
|
74955
|
+
async deleteUser(params) {
|
|
74937
74956
|
await this.client.request({
|
|
74938
|
-
service: "
|
|
74957
|
+
service: "connect",
|
|
74939
74958
|
region: this.region,
|
|
74940
|
-
method: "
|
|
74941
|
-
path:
|
|
74959
|
+
method: "DELETE",
|
|
74960
|
+
path: `/users/${params.InstanceId}/${params.UserId}`
|
|
74961
|
+
});
|
|
74962
|
+
}
|
|
74963
|
+
async listUsers(params) {
|
|
74964
|
+
const queryParams = {};
|
|
74965
|
+
if (params.NextToken)
|
|
74966
|
+
queryParams.nextToken = params.NextToken;
|
|
74967
|
+
if (params.MaxResults)
|
|
74968
|
+
queryParams.maxResults = String(params.MaxResults);
|
|
74969
|
+
return this.client.request({
|
|
74970
|
+
service: "connect",
|
|
74971
|
+
region: this.region,
|
|
74972
|
+
method: "GET",
|
|
74973
|
+
path: `/users-summary/${params.InstanceId}`,
|
|
74974
|
+
queryParams
|
|
74975
|
+
});
|
|
74976
|
+
}
|
|
74977
|
+
async createPrompt(params) {
|
|
74978
|
+
const body = {
|
|
74979
|
+
Name: params.Name,
|
|
74980
|
+
S3Uri: params.S3Uri
|
|
74981
|
+
};
|
|
74982
|
+
if (params.Description)
|
|
74983
|
+
body.Description = params.Description;
|
|
74984
|
+
if (params.Tags)
|
|
74985
|
+
body.Tags = params.Tags;
|
|
74986
|
+
return this.client.request({
|
|
74987
|
+
service: "connect",
|
|
74988
|
+
region: this.region,
|
|
74989
|
+
method: "PUT",
|
|
74990
|
+
path: `/prompts/${params.InstanceId}`,
|
|
74942
74991
|
headers: {
|
|
74943
|
-
"Content-Type": "application/
|
|
74992
|
+
"Content-Type": "application/json"
|
|
74944
74993
|
},
|
|
74945
|
-
body:
|
|
74994
|
+
body: JSON.stringify(body)
|
|
74946
74995
|
});
|
|
74947
74996
|
}
|
|
74948
|
-
async
|
|
74949
|
-
const
|
|
74950
|
-
|
|
74997
|
+
async listPrompts(params) {
|
|
74998
|
+
const queryParams = {};
|
|
74999
|
+
if (params.NextToken)
|
|
75000
|
+
queryParams.nextToken = params.NextToken;
|
|
75001
|
+
if (params.MaxResults)
|
|
75002
|
+
queryParams.maxResults = String(params.MaxResults);
|
|
75003
|
+
return this.client.request({
|
|
75004
|
+
service: "connect",
|
|
75005
|
+
region: this.region,
|
|
75006
|
+
method: "GET",
|
|
75007
|
+
path: `/prompts-summary/${params.InstanceId}`,
|
|
75008
|
+
queryParams
|
|
75009
|
+
});
|
|
75010
|
+
}
|
|
75011
|
+
async createQuickConnect(params) {
|
|
75012
|
+
const body = {
|
|
75013
|
+
Name: params.Name,
|
|
75014
|
+
QuickConnectConfig: params.QuickConnectConfig
|
|
74951
75015
|
};
|
|
74952
|
-
if (
|
|
74953
|
-
|
|
74954
|
-
if (
|
|
74955
|
-
|
|
74956
|
-
|
|
74957
|
-
|
|
74958
|
-
if (options.Certificates) {
|
|
74959
|
-
options.Certificates.forEach((cert, index) => {
|
|
74960
|
-
params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
|
|
74961
|
-
});
|
|
74962
|
-
}
|
|
74963
|
-
if (options.DefaultActions) {
|
|
74964
|
-
options.DefaultActions.forEach((action, index) => {
|
|
74965
|
-
if (action.Type)
|
|
74966
|
-
params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
|
|
74967
|
-
if (action.TargetGroupArn)
|
|
74968
|
-
params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
|
|
74969
|
-
if (action.Order !== undefined)
|
|
74970
|
-
params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
|
|
74971
|
-
});
|
|
74972
|
-
}
|
|
74973
|
-
if (options.AlpnPolicy) {
|
|
74974
|
-
options.AlpnPolicy.forEach((policy, index) => {
|
|
74975
|
-
params[`AlpnPolicy.member.${index + 1}`] = policy;
|
|
74976
|
-
});
|
|
74977
|
-
}
|
|
74978
|
-
const result = await this.client.request({
|
|
74979
|
-
service: "elasticloadbalancing",
|
|
75016
|
+
if (params.Description)
|
|
75017
|
+
body.Description = params.Description;
|
|
75018
|
+
if (params.Tags)
|
|
75019
|
+
body.Tags = params.Tags;
|
|
75020
|
+
return this.client.request({
|
|
75021
|
+
service: "connect",
|
|
74980
75022
|
region: this.region,
|
|
74981
|
-
method: "
|
|
74982
|
-
path:
|
|
75023
|
+
method: "PUT",
|
|
75024
|
+
path: `/quick-connects/${params.InstanceId}`,
|
|
74983
75025
|
headers: {
|
|
74984
|
-
"Content-Type": "application/
|
|
75026
|
+
"Content-Type": "application/json"
|
|
74985
75027
|
},
|
|
74986
|
-
body:
|
|
75028
|
+
body: JSON.stringify(body)
|
|
74987
75029
|
});
|
|
74988
|
-
return this.normalizeResult(result, "ModifyListenerResult");
|
|
74989
75030
|
}
|
|
74990
|
-
|
|
74991
|
-
|
|
74992
|
-
|
|
74993
|
-
|
|
74994
|
-
|
|
74995
|
-
|
|
74996
|
-
|
|
74997
|
-
|
|
74998
|
-
}
|
|
74999
|
-
|
|
75000
|
-
|
|
75031
|
+
async startChatContact(params) {
|
|
75032
|
+
return this.client.request({
|
|
75033
|
+
service: "connect",
|
|
75034
|
+
region: this.region,
|
|
75035
|
+
method: "PUT",
|
|
75036
|
+
path: `/contact/chat/${params.InstanceId}`,
|
|
75037
|
+
headers: {
|
|
75038
|
+
"Content-Type": "application/json"
|
|
75039
|
+
},
|
|
75040
|
+
body: JSON.stringify(params)
|
|
75041
|
+
});
|
|
75001
75042
|
}
|
|
75002
|
-
|
|
75003
|
-
|
|
75004
|
-
|
|
75005
|
-
|
|
75006
|
-
|
|
75007
|
-
|
|
75008
|
-
|
|
75009
|
-
|
|
75010
|
-
|
|
75043
|
+
async startTaskContact(params) {
|
|
75044
|
+
return this.client.request({
|
|
75045
|
+
service: "connect",
|
|
75046
|
+
region: this.region,
|
|
75047
|
+
method: "PUT",
|
|
75048
|
+
path: `/contact/task/${params.InstanceId}`,
|
|
75049
|
+
headers: {
|
|
75050
|
+
"Content-Type": "application/json"
|
|
75051
|
+
},
|
|
75052
|
+
body: JSON.stringify(params)
|
|
75053
|
+
});
|
|
75011
75054
|
}
|
|
75012
|
-
|
|
75013
|
-
|
|
75014
|
-
|
|
75015
|
-
|
|
75016
|
-
|
|
75017
|
-
|
|
75018
|
-
|
|
75019
|
-
|
|
75020
|
-
|
|
75021
|
-
|
|
75022
|
-
|
|
75023
|
-
|
|
75024
|
-
|
|
75025
|
-
|
|
75026
|
-
|
|
75027
|
-
|
|
75028
|
-
|
|
75029
|
-
|
|
75030
|
-
|
|
75031
|
-
|
|
75032
|
-
|
|
75033
|
-
|
|
75034
|
-
|
|
75035
|
-
|
|
75036
|
-
if (key === "member") {
|
|
75037
|
-
if (Array.isArray(value)) {
|
|
75038
|
-
return value.map((item) => this.normalizeArrays(item));
|
|
75055
|
+
createOutboundIvrFlow(params) {
|
|
75056
|
+
const voiceId = params.voiceId || "Joanna";
|
|
75057
|
+
return JSON.stringify({
|
|
75058
|
+
Version: "2019-10-30",
|
|
75059
|
+
StartAction: "play-prompt",
|
|
75060
|
+
Actions: {
|
|
75061
|
+
"play-prompt": {
|
|
75062
|
+
Type: "MessageParticipant",
|
|
75063
|
+
Parameters: {
|
|
75064
|
+
Text: params.message,
|
|
75065
|
+
TextToSpeechVoice: voiceId,
|
|
75066
|
+
TextToSpeechEngine: "neural"
|
|
75067
|
+
},
|
|
75068
|
+
Transitions: {
|
|
75069
|
+
NextAction: "disconnect",
|
|
75070
|
+
Errors: [
|
|
75071
|
+
{ NextAction: "disconnect", ErrorType: "NoMatchingError" }
|
|
75072
|
+
]
|
|
75073
|
+
}
|
|
75074
|
+
},
|
|
75075
|
+
disconnect: {
|
|
75076
|
+
Type: "DisconnectParticipant",
|
|
75077
|
+
Parameters: {},
|
|
75078
|
+
Transitions: {}
|
|
75039
75079
|
}
|
|
75040
|
-
return [this.normalizeArrays(value)];
|
|
75041
75080
|
}
|
|
75042
|
-
|
|
75043
|
-
|
|
75044
|
-
|
|
75045
|
-
|
|
75046
|
-
|
|
75047
|
-
|
|
75048
|
-
|
|
75049
|
-
|
|
75050
|
-
|
|
75051
|
-
|
|
75081
|
+
});
|
|
75082
|
+
}
|
|
75083
|
+
createInputCollectionFlow(params) {
|
|
75084
|
+
const voiceId = params.voiceId || "Joanna";
|
|
75085
|
+
const timeout = params.inputTimeout || 5;
|
|
75086
|
+
const maxDigits = params.maxDigits || 1;
|
|
75087
|
+
return JSON.stringify({
|
|
75088
|
+
Version: "2019-10-30",
|
|
75089
|
+
StartAction: "get-input",
|
|
75090
|
+
Actions: {
|
|
75091
|
+
"get-input": {
|
|
75092
|
+
Type: "GetParticipantInput",
|
|
75093
|
+
Parameters: {
|
|
75094
|
+
Text: params.promptMessage,
|
|
75095
|
+
TextToSpeechVoice: voiceId,
|
|
75096
|
+
TextToSpeechEngine: "neural",
|
|
75097
|
+
InputTimeLimitSeconds: String(timeout),
|
|
75098
|
+
MaxDigits: maxDigits,
|
|
75099
|
+
EncryptEntry: false
|
|
75100
|
+
},
|
|
75101
|
+
Transitions: {
|
|
75102
|
+
NextAction: params.successNextAction || "disconnect",
|
|
75103
|
+
Conditions: [],
|
|
75104
|
+
Errors: [
|
|
75105
|
+
{ NextAction: "disconnect", ErrorType: "NoMatchingCondition" },
|
|
75106
|
+
{ NextAction: "disconnect", ErrorType: "NoMatchingError" }
|
|
75107
|
+
]
|
|
75108
|
+
}
|
|
75109
|
+
},
|
|
75110
|
+
disconnect: {
|
|
75111
|
+
Type: "DisconnectParticipant",
|
|
75112
|
+
Parameters: {},
|
|
75113
|
+
Transitions: {}
|
|
75052
75114
|
}
|
|
75053
|
-
} else if (typeof value === "object") {
|
|
75054
|
-
result[key] = this.normalizeArrays(value);
|
|
75055
|
-
} else {
|
|
75056
|
-
result[key] = value;
|
|
75057
75115
|
}
|
|
75058
|
-
}
|
|
75059
|
-
|
|
75116
|
+
});
|
|
75117
|
+
}
|
|
75118
|
+
async getCurrentMetricData(params) {
|
|
75119
|
+
return this.client.request({
|
|
75120
|
+
service: "connect",
|
|
75121
|
+
region: this.region,
|
|
75122
|
+
method: "POST",
|
|
75123
|
+
path: `/metrics/current/${params.InstanceId}`,
|
|
75124
|
+
headers: {
|
|
75125
|
+
"Content-Type": "application/json"
|
|
75126
|
+
},
|
|
75127
|
+
body: JSON.stringify(params)
|
|
75128
|
+
});
|
|
75060
75129
|
}
|
|
75061
75130
|
}
|
|
75062
|
-
// src/aws/
|
|
75131
|
+
// src/aws/elbv2.ts
|
|
75063
75132
|
init_client();
|
|
75064
75133
|
|
|
75065
|
-
class
|
|
75134
|
+
class ELBv2Client {
|
|
75066
75135
|
client;
|
|
75067
75136
|
region;
|
|
75068
75137
|
constructor(region = "us-east-1") {
|
|
75069
75138
|
this.region = region;
|
|
75070
75139
|
this.client = new AWSClient;
|
|
75071
75140
|
}
|
|
75072
|
-
async
|
|
75073
|
-
const params = {
|
|
75074
|
-
|
|
75075
|
-
|
|
75076
|
-
|
|
75077
|
-
|
|
75078
|
-
params.DBInstanceIdentifier = options.DBInstanceIdentifier;
|
|
75141
|
+
async describeLoadBalancers(options) {
|
|
75142
|
+
const params = {};
|
|
75143
|
+
if (options?.LoadBalancerArns) {
|
|
75144
|
+
options.LoadBalancerArns.forEach((arn, index) => {
|
|
75145
|
+
params[`LoadBalancerArns.member.${index + 1}`] = arn;
|
|
75146
|
+
});
|
|
75079
75147
|
}
|
|
75080
|
-
if (options?.
|
|
75081
|
-
|
|
75148
|
+
if (options?.Names) {
|
|
75149
|
+
options.Names.forEach((name, index) => {
|
|
75150
|
+
params[`Names.member.${index + 1}`] = name;
|
|
75151
|
+
});
|
|
75082
75152
|
}
|
|
75083
75153
|
if (options?.Marker) {
|
|
75084
75154
|
params.Marker = options.Marker;
|
|
75085
75155
|
}
|
|
75086
|
-
if (options?.
|
|
75087
|
-
|
|
75088
|
-
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
75089
|
-
filter.Values.forEach((value, j) => {
|
|
75090
|
-
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
75091
|
-
});
|
|
75092
|
-
});
|
|
75156
|
+
if (options?.PageSize) {
|
|
75157
|
+
params.PageSize = options.PageSize;
|
|
75093
75158
|
}
|
|
75094
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75095
75159
|
const result = await this.client.request({
|
|
75096
|
-
service: "
|
|
75160
|
+
service: "elasticloadbalancing",
|
|
75097
75161
|
region: this.region,
|
|
75098
75162
|
method: "POST",
|
|
75099
75163
|
path: "/",
|
|
75100
75164
|
headers: {
|
|
75101
75165
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75102
75166
|
},
|
|
75103
|
-
body:
|
|
75167
|
+
body: this.buildFormBody("DescribeLoadBalancers", params)
|
|
75104
75168
|
});
|
|
75105
|
-
|
|
75106
|
-
let instances = response.DBInstances?.DBInstance || [];
|
|
75107
|
-
if (!Array.isArray(instances)) {
|
|
75108
|
-
instances = instances ? [instances] : [];
|
|
75109
|
-
}
|
|
75110
|
-
return {
|
|
75111
|
-
DBInstances: instances,
|
|
75112
|
-
Marker: response.Marker
|
|
75113
|
-
};
|
|
75114
|
-
}
|
|
75115
|
-
async describeDBInstance(dbInstanceIdentifier) {
|
|
75116
|
-
const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
|
|
75117
|
-
return result.DBInstances?.[0];
|
|
75169
|
+
return this.normalizeResult(result, "DescribeLoadBalancersResult");
|
|
75118
75170
|
}
|
|
75119
|
-
async
|
|
75120
|
-
const params = {
|
|
75121
|
-
|
|
75122
|
-
|
|
75123
|
-
};
|
|
75124
|
-
if (options?.DBClusterIdentifier) {
|
|
75125
|
-
params.DBClusterIdentifier = options.DBClusterIdentifier;
|
|
75171
|
+
async describeTargetGroups(options) {
|
|
75172
|
+
const params = {};
|
|
75173
|
+
if (options?.LoadBalancerArn) {
|
|
75174
|
+
params.LoadBalancerArn = options.LoadBalancerArn;
|
|
75126
75175
|
}
|
|
75127
|
-
if (options?.
|
|
75128
|
-
|
|
75176
|
+
if (options?.TargetGroupArns) {
|
|
75177
|
+
options.TargetGroupArns.forEach((arn, index) => {
|
|
75178
|
+
params[`TargetGroupArns.member.${index + 1}`] = arn;
|
|
75179
|
+
});
|
|
75180
|
+
}
|
|
75181
|
+
if (options?.Names) {
|
|
75182
|
+
options.Names.forEach((name, index) => {
|
|
75183
|
+
params[`Names.member.${index + 1}`] = name;
|
|
75184
|
+
});
|
|
75129
75185
|
}
|
|
75130
75186
|
if (options?.Marker) {
|
|
75131
75187
|
params.Marker = options.Marker;
|
|
75132
75188
|
}
|
|
75133
|
-
if (options?.
|
|
75134
|
-
|
|
75135
|
-
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
75136
|
-
filter.Values.forEach((value, j) => {
|
|
75137
|
-
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
75138
|
-
});
|
|
75139
|
-
});
|
|
75189
|
+
if (options?.PageSize) {
|
|
75190
|
+
params.PageSize = options.PageSize;
|
|
75140
75191
|
}
|
|
75141
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75142
75192
|
const result = await this.client.request({
|
|
75143
|
-
service: "
|
|
75193
|
+
service: "elasticloadbalancing",
|
|
75144
75194
|
region: this.region,
|
|
75145
75195
|
method: "POST",
|
|
75146
75196
|
path: "/",
|
|
75147
75197
|
headers: {
|
|
75148
75198
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75149
75199
|
},
|
|
75150
|
-
body:
|
|
75200
|
+
body: this.buildFormBody("DescribeTargetGroups", params)
|
|
75151
75201
|
});
|
|
75152
|
-
|
|
75153
|
-
let clusters = response.DBClusters?.DBCluster || [];
|
|
75154
|
-
if (!Array.isArray(clusters)) {
|
|
75155
|
-
clusters = clusters ? [clusters] : [];
|
|
75156
|
-
}
|
|
75157
|
-
return {
|
|
75158
|
-
DBClusters: clusters,
|
|
75159
|
-
Marker: response.Marker
|
|
75160
|
-
};
|
|
75202
|
+
return this.normalizeResult(result, "DescribeTargetGroupsResult");
|
|
75161
75203
|
}
|
|
75162
|
-
async
|
|
75204
|
+
async describeTargetHealth(options) {
|
|
75163
75205
|
const params = {
|
|
75164
|
-
|
|
75165
|
-
Version: "2014-10-31"
|
|
75206
|
+
TargetGroupArn: options.TargetGroupArn
|
|
75166
75207
|
};
|
|
75167
|
-
if (options
|
|
75168
|
-
|
|
75169
|
-
|
|
75170
|
-
|
|
75171
|
-
|
|
75172
|
-
|
|
75173
|
-
|
|
75174
|
-
|
|
75175
|
-
|
|
75176
|
-
|
|
75177
|
-
params.MaxRecords = options.MaxRecords;
|
|
75178
|
-
}
|
|
75179
|
-
if (options?.Marker) {
|
|
75180
|
-
params.Marker = options.Marker;
|
|
75208
|
+
if (options.Targets) {
|
|
75209
|
+
options.Targets.forEach((target, index) => {
|
|
75210
|
+
params[`Targets.member.${index + 1}.Id`] = target.Id;
|
|
75211
|
+
if (target.Port) {
|
|
75212
|
+
params[`Targets.member.${index + 1}.Port`] = target.Port;
|
|
75213
|
+
}
|
|
75214
|
+
if (target.AvailabilityZone) {
|
|
75215
|
+
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
75216
|
+
}
|
|
75217
|
+
});
|
|
75181
75218
|
}
|
|
75182
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75183
75219
|
const result = await this.client.request({
|
|
75184
|
-
service: "
|
|
75220
|
+
service: "elasticloadbalancing",
|
|
75185
75221
|
region: this.region,
|
|
75186
75222
|
method: "POST",
|
|
75187
75223
|
path: "/",
|
|
75188
75224
|
headers: {
|
|
75189
75225
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75190
75226
|
},
|
|
75191
|
-
body:
|
|
75227
|
+
body: this.buildFormBody("DescribeTargetHealth", params)
|
|
75192
75228
|
});
|
|
75193
|
-
|
|
75194
|
-
let snapshots = response.DBSnapshots?.DBSnapshot || [];
|
|
75195
|
-
if (!Array.isArray(snapshots)) {
|
|
75196
|
-
snapshots = snapshots ? [snapshots] : [];
|
|
75197
|
-
}
|
|
75198
|
-
return {
|
|
75199
|
-
DBSnapshots: snapshots,
|
|
75200
|
-
Marker: response.Marker
|
|
75201
|
-
};
|
|
75229
|
+
return this.normalizeResult(result, "DescribeTargetHealthResult");
|
|
75202
75230
|
}
|
|
75203
|
-
async
|
|
75204
|
-
const params = {
|
|
75205
|
-
|
|
75206
|
-
|
|
75207
|
-
};
|
|
75208
|
-
if (options?.DBSubnetGroupName) {
|
|
75209
|
-
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
75231
|
+
async describeListeners(options) {
|
|
75232
|
+
const params = {};
|
|
75233
|
+
if (options?.LoadBalancerArn) {
|
|
75234
|
+
params.LoadBalancerArn = options.LoadBalancerArn;
|
|
75210
75235
|
}
|
|
75211
|
-
if (options?.
|
|
75212
|
-
|
|
75236
|
+
if (options?.ListenerArns) {
|
|
75237
|
+
options.ListenerArns.forEach((arn, index) => {
|
|
75238
|
+
params[`ListenerArns.member.${index + 1}`] = arn;
|
|
75239
|
+
});
|
|
75213
75240
|
}
|
|
75214
75241
|
if (options?.Marker) {
|
|
75215
75242
|
params.Marker = options.Marker;
|
|
75216
75243
|
}
|
|
75217
|
-
|
|
75244
|
+
if (options?.PageSize) {
|
|
75245
|
+
params.PageSize = options.PageSize;
|
|
75246
|
+
}
|
|
75218
75247
|
const result = await this.client.request({
|
|
75219
|
-
service: "
|
|
75248
|
+
service: "elasticloadbalancing",
|
|
75220
75249
|
region: this.region,
|
|
75221
75250
|
method: "POST",
|
|
75222
75251
|
path: "/",
|
|
75223
75252
|
headers: {
|
|
75224
75253
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75225
75254
|
},
|
|
75226
|
-
body:
|
|
75255
|
+
body: this.buildFormBody("DescribeListeners", params)
|
|
75227
75256
|
});
|
|
75228
|
-
|
|
75229
|
-
let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
|
|
75230
|
-
if (!Array.isArray(groups)) {
|
|
75231
|
-
groups = groups ? [groups] : [];
|
|
75232
|
-
}
|
|
75233
|
-
return {
|
|
75234
|
-
DBSubnetGroups: groups,
|
|
75235
|
-
Marker: response.Marker
|
|
75236
|
-
};
|
|
75257
|
+
return this.normalizeResult(result, "DescribeListenersResult");
|
|
75237
75258
|
}
|
|
75238
|
-
async
|
|
75239
|
-
const params = {
|
|
75240
|
-
|
|
75241
|
-
|
|
75242
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
75243
|
-
DBInstanceClass: options.DBInstanceClass,
|
|
75244
|
-
Engine: options.Engine
|
|
75245
|
-
};
|
|
75246
|
-
if (options.MasterUsername)
|
|
75247
|
-
params.MasterUsername = options.MasterUsername;
|
|
75248
|
-
if (options.MasterUserPassword)
|
|
75249
|
-
params.MasterUserPassword = options.MasterUserPassword;
|
|
75250
|
-
if (options.DBName)
|
|
75251
|
-
params.DBName = options.DBName;
|
|
75252
|
-
if (options.AllocatedStorage)
|
|
75253
|
-
params.AllocatedStorage = options.AllocatedStorage;
|
|
75254
|
-
if (options.DBSubnetGroupName)
|
|
75255
|
-
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
75256
|
-
if (options.AvailabilityZone)
|
|
75257
|
-
params.AvailabilityZone = options.AvailabilityZone;
|
|
75258
|
-
if (options.PreferredMaintenanceWindow)
|
|
75259
|
-
params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
|
|
75260
|
-
if (options.PreferredBackupWindow)
|
|
75261
|
-
params.PreferredBackupWindow = options.PreferredBackupWindow;
|
|
75262
|
-
if (options.BackupRetentionPeriod !== undefined)
|
|
75263
|
-
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
75264
|
-
if (options.MultiAZ !== undefined)
|
|
75265
|
-
params.MultiAZ = options.MultiAZ;
|
|
75266
|
-
if (options.EngineVersion)
|
|
75267
|
-
params.EngineVersion = options.EngineVersion;
|
|
75268
|
-
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
75269
|
-
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
75270
|
-
if (options.LicenseModel)
|
|
75271
|
-
params.LicenseModel = options.LicenseModel;
|
|
75272
|
-
if (options.PubliclyAccessible !== undefined)
|
|
75273
|
-
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
75274
|
-
if (options.StorageType)
|
|
75275
|
-
params.StorageType = options.StorageType;
|
|
75276
|
-
if (options.StorageEncrypted !== undefined)
|
|
75277
|
-
params.StorageEncrypted = options.StorageEncrypted;
|
|
75278
|
-
if (options.KmsKeyId)
|
|
75279
|
-
params.KmsKeyId = options.KmsKeyId;
|
|
75280
|
-
if (options.DeletionProtection !== undefined)
|
|
75281
|
-
params.DeletionProtection = options.DeletionProtection;
|
|
75282
|
-
if (options.VpcSecurityGroupIds) {
|
|
75283
|
-
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
75284
|
-
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
75285
|
-
});
|
|
75259
|
+
async describeRules(options) {
|
|
75260
|
+
const params = {};
|
|
75261
|
+
if (options?.ListenerArn) {
|
|
75262
|
+
params.ListenerArn = options.ListenerArn;
|
|
75286
75263
|
}
|
|
75287
|
-
if (options
|
|
75288
|
-
options.
|
|
75289
|
-
params[`
|
|
75290
|
-
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
75264
|
+
if (options?.RuleArns) {
|
|
75265
|
+
options.RuleArns.forEach((arn, index) => {
|
|
75266
|
+
params[`RuleArns.member.${index + 1}`] = arn;
|
|
75291
75267
|
});
|
|
75292
75268
|
}
|
|
75293
|
-
|
|
75269
|
+
if (options?.Marker) {
|
|
75270
|
+
params.Marker = options.Marker;
|
|
75271
|
+
}
|
|
75272
|
+
if (options?.PageSize) {
|
|
75273
|
+
params.PageSize = options.PageSize;
|
|
75274
|
+
}
|
|
75294
75275
|
const result = await this.client.request({
|
|
75295
|
-
service: "
|
|
75276
|
+
service: "elasticloadbalancing",
|
|
75296
75277
|
region: this.region,
|
|
75297
75278
|
method: "POST",
|
|
75298
75279
|
path: "/",
|
|
75299
75280
|
headers: {
|
|
75300
75281
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75301
75282
|
},
|
|
75302
|
-
body:
|
|
75283
|
+
body: this.buildFormBody("DescribeRules", params)
|
|
75303
75284
|
});
|
|
75304
|
-
|
|
75305
|
-
return {
|
|
75306
|
-
DBInstance: response.DBInstance
|
|
75307
|
-
};
|
|
75285
|
+
return this.normalizeResult(result, "DescribeRulesResult");
|
|
75308
75286
|
}
|
|
75309
|
-
async
|
|
75287
|
+
async describeLoadBalancerAttributes(loadBalancerArn) {
|
|
75310
75288
|
const params = {
|
|
75311
|
-
|
|
75312
|
-
Version: "2014-10-31",
|
|
75313
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
75289
|
+
LoadBalancerArn: loadBalancerArn
|
|
75314
75290
|
};
|
|
75315
|
-
if (options.SkipFinalSnapshot !== undefined) {
|
|
75316
|
-
params.SkipFinalSnapshot = options.SkipFinalSnapshot;
|
|
75317
|
-
}
|
|
75318
|
-
if (options.FinalDBSnapshotIdentifier) {
|
|
75319
|
-
params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
|
|
75320
|
-
}
|
|
75321
|
-
if (options.DeleteAutomatedBackups !== undefined) {
|
|
75322
|
-
params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
|
|
75323
|
-
}
|
|
75324
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75325
75291
|
const result = await this.client.request({
|
|
75326
|
-
service: "
|
|
75292
|
+
service: "elasticloadbalancing",
|
|
75327
75293
|
region: this.region,
|
|
75328
75294
|
method: "POST",
|
|
75329
75295
|
path: "/",
|
|
75330
75296
|
headers: {
|
|
75331
75297
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75332
75298
|
},
|
|
75333
|
-
body:
|
|
75299
|
+
body: this.buildFormBody("DescribeLoadBalancerAttributes", params)
|
|
75334
75300
|
});
|
|
75335
|
-
|
|
75336
|
-
|
|
75337
|
-
|
|
75301
|
+
return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
|
|
75302
|
+
}
|
|
75303
|
+
async describeTargetGroupAttributes(targetGroupArn) {
|
|
75304
|
+
const params = {
|
|
75305
|
+
TargetGroupArn: targetGroupArn
|
|
75338
75306
|
};
|
|
75307
|
+
const result = await this.client.request({
|
|
75308
|
+
service: "elasticloadbalancing",
|
|
75309
|
+
region: this.region,
|
|
75310
|
+
method: "POST",
|
|
75311
|
+
path: "/",
|
|
75312
|
+
headers: {
|
|
75313
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
75314
|
+
},
|
|
75315
|
+
body: this.buildFormBody("DescribeTargetGroupAttributes", params)
|
|
75316
|
+
});
|
|
75317
|
+
return this.normalizeResult(result, "DescribeTargetGroupAttributesResult");
|
|
75339
75318
|
}
|
|
75340
|
-
async
|
|
75319
|
+
async createLoadBalancer(options) {
|
|
75341
75320
|
const params = {
|
|
75342
|
-
|
|
75343
|
-
Version: "2014-10-31",
|
|
75344
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
75321
|
+
Name: options.Name
|
|
75345
75322
|
};
|
|
75346
|
-
if (options.
|
|
75347
|
-
|
|
75348
|
-
|
|
75349
|
-
|
|
75350
|
-
|
|
75351
|
-
|
|
75352
|
-
|
|
75353
|
-
|
|
75354
|
-
|
|
75355
|
-
|
|
75356
|
-
|
|
75357
|
-
|
|
75358
|
-
|
|
75359
|
-
|
|
75360
|
-
|
|
75361
|
-
|
|
75362
|
-
|
|
75363
|
-
|
|
75364
|
-
|
|
75365
|
-
|
|
75366
|
-
|
|
75367
|
-
|
|
75368
|
-
|
|
75369
|
-
|
|
75370
|
-
if (options.
|
|
75371
|
-
params.
|
|
75372
|
-
|
|
75373
|
-
|
|
75374
|
-
|
|
75323
|
+
if (options.Subnets) {
|
|
75324
|
+
options.Subnets.forEach((subnet, index) => {
|
|
75325
|
+
params[`Subnets.member.${index + 1}`] = subnet;
|
|
75326
|
+
});
|
|
75327
|
+
}
|
|
75328
|
+
if (options.SubnetMappings) {
|
|
75329
|
+
options.SubnetMappings.forEach((mapping, index) => {
|
|
75330
|
+
params[`SubnetMappings.member.${index + 1}.SubnetId`] = mapping.SubnetId;
|
|
75331
|
+
if (mapping.AllocationId) {
|
|
75332
|
+
params[`SubnetMappings.member.${index + 1}.AllocationId`] = mapping.AllocationId;
|
|
75333
|
+
}
|
|
75334
|
+
if (mapping.PrivateIPv4Address) {
|
|
75335
|
+
params[`SubnetMappings.member.${index + 1}.PrivateIPv4Address`] = mapping.PrivateIPv4Address;
|
|
75336
|
+
}
|
|
75337
|
+
if (mapping.IPv6Address) {
|
|
75338
|
+
params[`SubnetMappings.member.${index + 1}.IPv6Address`] = mapping.IPv6Address;
|
|
75339
|
+
}
|
|
75340
|
+
});
|
|
75341
|
+
}
|
|
75342
|
+
if (options.SecurityGroups) {
|
|
75343
|
+
options.SecurityGroups.forEach((sg, index) => {
|
|
75344
|
+
params[`SecurityGroups.member.${index + 1}`] = sg;
|
|
75345
|
+
});
|
|
75346
|
+
}
|
|
75347
|
+
if (options.Scheme) {
|
|
75348
|
+
params.Scheme = options.Scheme;
|
|
75349
|
+
}
|
|
75350
|
+
if (options.Type) {
|
|
75351
|
+
params.Type = options.Type;
|
|
75352
|
+
}
|
|
75353
|
+
if (options.IpAddressType) {
|
|
75354
|
+
params.IpAddressType = options.IpAddressType;
|
|
75355
|
+
}
|
|
75356
|
+
if (options.Tags) {
|
|
75357
|
+
options.Tags.forEach((tag, index) => {
|
|
75358
|
+
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
75359
|
+
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
75375
75360
|
});
|
|
75376
75361
|
}
|
|
75377
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75378
75362
|
const result = await this.client.request({
|
|
75379
|
-
service: "
|
|
75363
|
+
service: "elasticloadbalancing",
|
|
75380
75364
|
region: this.region,
|
|
75381
75365
|
method: "POST",
|
|
75382
75366
|
path: "/",
|
|
75383
75367
|
headers: {
|
|
75384
75368
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75385
75369
|
},
|
|
75386
|
-
body:
|
|
75370
|
+
body: this.buildFormBody("CreateLoadBalancer", params)
|
|
75387
75371
|
});
|
|
75388
|
-
|
|
75389
|
-
return {
|
|
75390
|
-
DBInstance: response.DBInstance
|
|
75391
|
-
};
|
|
75372
|
+
return this.normalizeResult(result, "CreateLoadBalancerResult");
|
|
75392
75373
|
}
|
|
75393
|
-
async
|
|
75374
|
+
async deleteLoadBalancer(loadBalancerArn) {
|
|
75394
75375
|
const params = {
|
|
75395
|
-
|
|
75396
|
-
Version: "2014-10-31",
|
|
75397
|
-
DBInstanceIdentifier: dbInstanceIdentifier
|
|
75376
|
+
LoadBalancerArn: loadBalancerArn
|
|
75398
75377
|
};
|
|
75399
|
-
|
|
75400
|
-
|
|
75401
|
-
service: "rds",
|
|
75378
|
+
await this.client.request({
|
|
75379
|
+
service: "elasticloadbalancing",
|
|
75402
75380
|
region: this.region,
|
|
75403
75381
|
method: "POST",
|
|
75404
75382
|
path: "/",
|
|
75405
75383
|
headers: {
|
|
75406
75384
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75407
75385
|
},
|
|
75408
|
-
body:
|
|
75386
|
+
body: this.buildFormBody("DeleteLoadBalancer", params)
|
|
75409
75387
|
});
|
|
75410
|
-
const response = result.StartDBInstanceResult || result;
|
|
75411
|
-
return {
|
|
75412
|
-
DBInstance: response.DBInstance
|
|
75413
|
-
};
|
|
75414
75388
|
}
|
|
75415
|
-
async
|
|
75389
|
+
async createTargetGroup(options) {
|
|
75416
75390
|
const params = {
|
|
75417
|
-
|
|
75418
|
-
Version: "2014-10-31",
|
|
75419
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
75391
|
+
Name: options.Name
|
|
75420
75392
|
};
|
|
75421
|
-
if (options.
|
|
75422
|
-
params.
|
|
75393
|
+
if (options.Protocol)
|
|
75394
|
+
params.Protocol = options.Protocol;
|
|
75395
|
+
if (options.ProtocolVersion)
|
|
75396
|
+
params.ProtocolVersion = options.ProtocolVersion;
|
|
75397
|
+
if (options.Port)
|
|
75398
|
+
params.Port = options.Port;
|
|
75399
|
+
if (options.VpcId)
|
|
75400
|
+
params.VpcId = options.VpcId;
|
|
75401
|
+
if (options.HealthCheckProtocol)
|
|
75402
|
+
params.HealthCheckProtocol = options.HealthCheckProtocol;
|
|
75403
|
+
if (options.HealthCheckPort)
|
|
75404
|
+
params.HealthCheckPort = options.HealthCheckPort;
|
|
75405
|
+
if (options.HealthCheckEnabled !== undefined)
|
|
75406
|
+
params.HealthCheckEnabled = options.HealthCheckEnabled;
|
|
75407
|
+
if (options.HealthCheckPath)
|
|
75408
|
+
params.HealthCheckPath = options.HealthCheckPath;
|
|
75409
|
+
if (options.HealthCheckIntervalSeconds)
|
|
75410
|
+
params.HealthCheckIntervalSeconds = options.HealthCheckIntervalSeconds;
|
|
75411
|
+
if (options.HealthCheckTimeoutSeconds)
|
|
75412
|
+
params.HealthCheckTimeoutSeconds = options.HealthCheckTimeoutSeconds;
|
|
75413
|
+
if (options.HealthyThresholdCount)
|
|
75414
|
+
params.HealthyThresholdCount = options.HealthyThresholdCount;
|
|
75415
|
+
if (options.UnhealthyThresholdCount)
|
|
75416
|
+
params.UnhealthyThresholdCount = options.UnhealthyThresholdCount;
|
|
75417
|
+
if (options.TargetType)
|
|
75418
|
+
params.TargetType = options.TargetType;
|
|
75419
|
+
if (options.IpAddressType)
|
|
75420
|
+
params.IpAddressType = options.IpAddressType;
|
|
75421
|
+
if (options.Matcher) {
|
|
75422
|
+
if (options.Matcher.HttpCode)
|
|
75423
|
+
params["Matcher.HttpCode"] = options.Matcher.HttpCode;
|
|
75424
|
+
if (options.Matcher.GrpcCode)
|
|
75425
|
+
params["Matcher.GrpcCode"] = options.Matcher.GrpcCode;
|
|
75426
|
+
}
|
|
75427
|
+
if (options.Tags) {
|
|
75428
|
+
options.Tags.forEach((tag, index) => {
|
|
75429
|
+
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
75430
|
+
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
75431
|
+
});
|
|
75423
75432
|
}
|
|
75424
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75425
75433
|
const result = await this.client.request({
|
|
75426
|
-
service: "
|
|
75434
|
+
service: "elasticloadbalancing",
|
|
75427
75435
|
region: this.region,
|
|
75428
75436
|
method: "POST",
|
|
75429
75437
|
path: "/",
|
|
75430
75438
|
headers: {
|
|
75431
75439
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75432
75440
|
},
|
|
75433
|
-
body:
|
|
75441
|
+
body: this.buildFormBody("CreateTargetGroup", params)
|
|
75434
75442
|
});
|
|
75435
|
-
|
|
75436
|
-
|
|
75437
|
-
|
|
75443
|
+
return this.normalizeResult(result, "CreateTargetGroupResult");
|
|
75444
|
+
}
|
|
75445
|
+
async deleteTargetGroup(targetGroupArn) {
|
|
75446
|
+
const params = {
|
|
75447
|
+
TargetGroupArn: targetGroupArn
|
|
75438
75448
|
};
|
|
75449
|
+
await this.client.request({
|
|
75450
|
+
service: "elasticloadbalancing",
|
|
75451
|
+
region: this.region,
|
|
75452
|
+
method: "POST",
|
|
75453
|
+
path: "/",
|
|
75454
|
+
headers: {
|
|
75455
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
75456
|
+
},
|
|
75457
|
+
body: this.buildFormBody("DeleteTargetGroup", params)
|
|
75458
|
+
});
|
|
75439
75459
|
}
|
|
75440
|
-
async
|
|
75460
|
+
async registerTargets(options) {
|
|
75441
75461
|
const params = {
|
|
75442
|
-
|
|
75443
|
-
Version: "2014-10-31",
|
|
75444
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
75462
|
+
TargetGroupArn: options.TargetGroupArn
|
|
75445
75463
|
};
|
|
75446
|
-
|
|
75447
|
-
params.
|
|
75448
|
-
|
|
75449
|
-
|
|
75450
|
-
|
|
75451
|
-
|
|
75464
|
+
options.Targets.forEach((target, index) => {
|
|
75465
|
+
params[`Targets.member.${index + 1}.Id`] = target.Id;
|
|
75466
|
+
if (target.Port) {
|
|
75467
|
+
params[`Targets.member.${index + 1}.Port`] = target.Port;
|
|
75468
|
+
}
|
|
75469
|
+
if (target.AvailabilityZone) {
|
|
75470
|
+
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
75471
|
+
}
|
|
75472
|
+
});
|
|
75473
|
+
await this.client.request({
|
|
75474
|
+
service: "elasticloadbalancing",
|
|
75452
75475
|
region: this.region,
|
|
75453
75476
|
method: "POST",
|
|
75454
75477
|
path: "/",
|
|
75455
75478
|
headers: {
|
|
75456
75479
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75457
75480
|
},
|
|
75458
|
-
body:
|
|
75481
|
+
body: this.buildFormBody("RegisterTargets", params)
|
|
75459
75482
|
});
|
|
75460
|
-
|
|
75461
|
-
|
|
75462
|
-
|
|
75483
|
+
}
|
|
75484
|
+
async deregisterTargets(options) {
|
|
75485
|
+
const params = {
|
|
75486
|
+
TargetGroupArn: options.TargetGroupArn
|
|
75463
75487
|
};
|
|
75488
|
+
options.Targets.forEach((target, index) => {
|
|
75489
|
+
params[`Targets.member.${index + 1}.Id`] = target.Id;
|
|
75490
|
+
if (target.Port) {
|
|
75491
|
+
params[`Targets.member.${index + 1}.Port`] = target.Port;
|
|
75492
|
+
}
|
|
75493
|
+
if (target.AvailabilityZone) {
|
|
75494
|
+
params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
|
|
75495
|
+
}
|
|
75496
|
+
});
|
|
75497
|
+
await this.client.request({
|
|
75498
|
+
service: "elasticloadbalancing",
|
|
75499
|
+
region: this.region,
|
|
75500
|
+
method: "POST",
|
|
75501
|
+
path: "/",
|
|
75502
|
+
headers: {
|
|
75503
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
75504
|
+
},
|
|
75505
|
+
body: this.buildFormBody("DeregisterTargets", params)
|
|
75506
|
+
});
|
|
75464
75507
|
}
|
|
75465
|
-
async
|
|
75508
|
+
async createListener(options) {
|
|
75466
75509
|
const params = {
|
|
75467
|
-
|
|
75468
|
-
|
|
75469
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
75470
|
-
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
75510
|
+
LoadBalancerArn: options.LoadBalancerArn,
|
|
75511
|
+
Port: options.Port
|
|
75471
75512
|
};
|
|
75513
|
+
if (options.Protocol)
|
|
75514
|
+
params.Protocol = options.Protocol;
|
|
75515
|
+
if (options.SslPolicy)
|
|
75516
|
+
params.SslPolicy = options.SslPolicy;
|
|
75517
|
+
if (options.Certificates) {
|
|
75518
|
+
options.Certificates.forEach((cert, index) => {
|
|
75519
|
+
params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
|
|
75520
|
+
});
|
|
75521
|
+
}
|
|
75522
|
+
options.DefaultActions.forEach((action, index) => {
|
|
75523
|
+
params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
|
|
75524
|
+
if (action.TargetGroupArn) {
|
|
75525
|
+
params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
|
|
75526
|
+
}
|
|
75527
|
+
if (action.Order !== undefined) {
|
|
75528
|
+
params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
|
|
75529
|
+
}
|
|
75530
|
+
if (action.RedirectConfig) {
|
|
75531
|
+
const rc = action.RedirectConfig;
|
|
75532
|
+
if (rc.Protocol)
|
|
75533
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.Protocol`] = rc.Protocol;
|
|
75534
|
+
if (rc.Port)
|
|
75535
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.Port`] = rc.Port;
|
|
75536
|
+
if (rc.Host)
|
|
75537
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.Host`] = rc.Host;
|
|
75538
|
+
if (rc.Path)
|
|
75539
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.Path`] = rc.Path;
|
|
75540
|
+
if (rc.Query)
|
|
75541
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.Query`] = rc.Query;
|
|
75542
|
+
params[`DefaultActions.member.${index + 1}.RedirectConfig.StatusCode`] = rc.StatusCode;
|
|
75543
|
+
}
|
|
75544
|
+
if (action.FixedResponseConfig) {
|
|
75545
|
+
const fr = action.FixedResponseConfig;
|
|
75546
|
+
if (fr.MessageBody)
|
|
75547
|
+
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.MessageBody`] = fr.MessageBody;
|
|
75548
|
+
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.StatusCode`] = fr.StatusCode;
|
|
75549
|
+
if (fr.ContentType)
|
|
75550
|
+
params[`DefaultActions.member.${index + 1}.FixedResponseConfig.ContentType`] = fr.ContentType;
|
|
75551
|
+
}
|
|
75552
|
+
});
|
|
75553
|
+
if (options.AlpnPolicy) {
|
|
75554
|
+
options.AlpnPolicy.forEach((policy, index) => {
|
|
75555
|
+
params[`AlpnPolicy.member.${index + 1}`] = policy;
|
|
75556
|
+
});
|
|
75557
|
+
}
|
|
75472
75558
|
if (options.Tags) {
|
|
75473
|
-
options.Tags.forEach((tag,
|
|
75474
|
-
params[`Tags.
|
|
75475
|
-
params[`Tags.
|
|
75559
|
+
options.Tags.forEach((tag, index) => {
|
|
75560
|
+
params[`Tags.member.${index + 1}.Key`] = tag.Key;
|
|
75561
|
+
params[`Tags.member.${index + 1}.Value`] = tag.Value;
|
|
75476
75562
|
});
|
|
75477
75563
|
}
|
|
75478
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75479
75564
|
const result = await this.client.request({
|
|
75480
|
-
service: "
|
|
75565
|
+
service: "elasticloadbalancing",
|
|
75481
75566
|
region: this.region,
|
|
75482
75567
|
method: "POST",
|
|
75483
75568
|
path: "/",
|
|
75484
75569
|
headers: {
|
|
75485
75570
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75486
75571
|
},
|
|
75487
|
-
body:
|
|
75572
|
+
body: this.buildFormBody("CreateListener", params)
|
|
75488
75573
|
});
|
|
75489
|
-
|
|
75490
|
-
return {
|
|
75491
|
-
DBSnapshot: response.DBSnapshot
|
|
75492
|
-
};
|
|
75574
|
+
return this.normalizeResult(result, "CreateListenerResult");
|
|
75493
75575
|
}
|
|
75494
|
-
async
|
|
75576
|
+
async deleteListener(listenerArn) {
|
|
75495
75577
|
const params = {
|
|
75496
|
-
|
|
75497
|
-
Version: "2014-10-31",
|
|
75498
|
-
DBSnapshotIdentifier: dbSnapshotIdentifier
|
|
75578
|
+
ListenerArn: listenerArn
|
|
75499
75579
|
};
|
|
75500
|
-
|
|
75501
|
-
|
|
75502
|
-
service: "rds",
|
|
75580
|
+
await this.client.request({
|
|
75581
|
+
service: "elasticloadbalancing",
|
|
75503
75582
|
region: this.region,
|
|
75504
75583
|
method: "POST",
|
|
75505
75584
|
path: "/",
|
|
75506
75585
|
headers: {
|
|
75507
75586
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75508
75587
|
},
|
|
75509
|
-
body:
|
|
75588
|
+
body: this.buildFormBody("DeleteListener", params)
|
|
75510
75589
|
});
|
|
75511
|
-
const response = result.DeleteDBSnapshotResult || result;
|
|
75512
|
-
return {
|
|
75513
|
-
DBSnapshot: response.DBSnapshot
|
|
75514
|
-
};
|
|
75515
75590
|
}
|
|
75516
|
-
async
|
|
75591
|
+
async modifyListener(options) {
|
|
75517
75592
|
const params = {
|
|
75518
|
-
|
|
75519
|
-
Version: "2014-10-31",
|
|
75520
|
-
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
75521
|
-
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
75593
|
+
ListenerArn: options.ListenerArn
|
|
75522
75594
|
};
|
|
75523
|
-
if (options.DBInstanceClass)
|
|
75524
|
-
params.DBInstanceClass = options.DBInstanceClass;
|
|
75525
75595
|
if (options.Port)
|
|
75526
75596
|
params.Port = options.Port;
|
|
75527
|
-
if (options.
|
|
75528
|
-
params.
|
|
75529
|
-
if (options.
|
|
75530
|
-
params.
|
|
75531
|
-
if (options.
|
|
75532
|
-
|
|
75533
|
-
|
|
75534
|
-
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
75535
|
-
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
75536
|
-
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
75537
|
-
if (options.StorageType)
|
|
75538
|
-
params.StorageType = options.StorageType;
|
|
75539
|
-
if (options.DeletionProtection !== undefined)
|
|
75540
|
-
params.DeletionProtection = options.DeletionProtection;
|
|
75541
|
-
if (options.VpcSecurityGroupIds) {
|
|
75542
|
-
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
75543
|
-
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
75597
|
+
if (options.Protocol)
|
|
75598
|
+
params.Protocol = options.Protocol;
|
|
75599
|
+
if (options.SslPolicy)
|
|
75600
|
+
params.SslPolicy = options.SslPolicy;
|
|
75601
|
+
if (options.Certificates) {
|
|
75602
|
+
options.Certificates.forEach((cert, index) => {
|
|
75603
|
+
params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
|
|
75544
75604
|
});
|
|
75545
75605
|
}
|
|
75546
|
-
if (options.
|
|
75547
|
-
options.
|
|
75548
|
-
|
|
75549
|
-
|
|
75606
|
+
if (options.DefaultActions) {
|
|
75607
|
+
options.DefaultActions.forEach((action, index) => {
|
|
75608
|
+
if (action.Type)
|
|
75609
|
+
params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
|
|
75610
|
+
if (action.TargetGroupArn)
|
|
75611
|
+
params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
|
|
75612
|
+
if (action.Order !== undefined)
|
|
75613
|
+
params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
|
|
75614
|
+
});
|
|
75615
|
+
}
|
|
75616
|
+
if (options.AlpnPolicy) {
|
|
75617
|
+
options.AlpnPolicy.forEach((policy, index) => {
|
|
75618
|
+
params[`AlpnPolicy.member.${index + 1}`] = policy;
|
|
75550
75619
|
});
|
|
75551
75620
|
}
|
|
75552
|
-
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
75553
75621
|
const result = await this.client.request({
|
|
75554
|
-
service: "
|
|
75622
|
+
service: "elasticloadbalancing",
|
|
75555
75623
|
region: this.region,
|
|
75556
75624
|
method: "POST",
|
|
75557
75625
|
path: "/",
|
|
75558
75626
|
headers: {
|
|
75559
75627
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75560
75628
|
},
|
|
75561
|
-
body:
|
|
75629
|
+
body: this.buildFormBody("ModifyListener", params)
|
|
75562
75630
|
});
|
|
75563
|
-
|
|
75564
|
-
return {
|
|
75565
|
-
DBInstance: response.DBInstance
|
|
75566
|
-
};
|
|
75631
|
+
return this.normalizeResult(result, "ModifyListenerResult");
|
|
75567
75632
|
}
|
|
75568
|
-
|
|
75569
|
-
|
|
75570
|
-
|
|
75571
|
-
|
|
75572
|
-
|
|
75573
|
-
|
|
75574
|
-
if (
|
|
75575
|
-
|
|
75633
|
+
buildFormBody(action, params) {
|
|
75634
|
+
const formParams = {
|
|
75635
|
+
Action: action,
|
|
75636
|
+
Version: "2015-12-01"
|
|
75637
|
+
};
|
|
75638
|
+
for (const [key, value] of Object.entries(params)) {
|
|
75639
|
+
if (value !== undefined && value !== null) {
|
|
75640
|
+
formParams[key] = String(value);
|
|
75576
75641
|
}
|
|
75577
|
-
await new Promise((resolve14) => setTimeout(resolve14, delayMs));
|
|
75578
75642
|
}
|
|
75579
|
-
|
|
75643
|
+
return Object.entries(formParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
75580
75644
|
}
|
|
75581
|
-
|
|
75582
|
-
|
|
75583
|
-
|
|
75584
|
-
|
|
75585
|
-
|
|
75586
|
-
|
|
75587
|
-
|
|
75645
|
+
normalizeResult(parsed, resultKey) {
|
|
75646
|
+
if (parsed && parsed[resultKey]) {
|
|
75647
|
+
return this.normalizeArrays(parsed[resultKey]);
|
|
75648
|
+
}
|
|
75649
|
+
const responseKey = resultKey.replace("Result", "Response");
|
|
75650
|
+
if (parsed && parsed[responseKey] && parsed[responseKey][resultKey]) {
|
|
75651
|
+
return this.normalizeArrays(parsed[responseKey][resultKey]);
|
|
75652
|
+
}
|
|
75653
|
+
return this.normalizeArrays(parsed);
|
|
75654
|
+
}
|
|
75655
|
+
normalizeArrays(obj) {
|
|
75656
|
+
if (!obj || typeof obj !== "object") {
|
|
75657
|
+
return obj;
|
|
75658
|
+
}
|
|
75659
|
+
if (Array.isArray(obj)) {
|
|
75660
|
+
return obj.map((item) => this.normalizeArrays(item));
|
|
75661
|
+
}
|
|
75662
|
+
const result = {};
|
|
75663
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
75664
|
+
const arrayFields = [
|
|
75665
|
+
"LoadBalancers",
|
|
75666
|
+
"TargetGroups",
|
|
75667
|
+
"Listeners",
|
|
75668
|
+
"Rules",
|
|
75669
|
+
"TargetHealthDescriptions",
|
|
75670
|
+
"Attributes",
|
|
75671
|
+
"SecurityGroups",
|
|
75672
|
+
"AvailabilityZones",
|
|
75673
|
+
"Certificates",
|
|
75674
|
+
"DefaultActions",
|
|
75675
|
+
"Conditions",
|
|
75676
|
+
"Actions",
|
|
75677
|
+
"member"
|
|
75678
|
+
];
|
|
75679
|
+
if (key === "member") {
|
|
75680
|
+
if (Array.isArray(value)) {
|
|
75681
|
+
return value.map((item) => this.normalizeArrays(item));
|
|
75588
75682
|
}
|
|
75589
|
-
|
|
75590
|
-
}
|
|
75591
|
-
|
|
75592
|
-
|
|
75683
|
+
return [this.normalizeArrays(value)];
|
|
75684
|
+
}
|
|
75685
|
+
if (arrayFields.includes(key)) {
|
|
75686
|
+
if (value && typeof value === "object" && "member" in value) {
|
|
75687
|
+
const memberValue = value.member;
|
|
75688
|
+
result[key] = Array.isArray(memberValue) ? memberValue.map((item) => this.normalizeArrays(item)) : [this.normalizeArrays(memberValue)];
|
|
75689
|
+
} else if (Array.isArray(value)) {
|
|
75690
|
+
result[key] = value.map((item) => this.normalizeArrays(item));
|
|
75691
|
+
} else if (value) {
|
|
75692
|
+
result[key] = [this.normalizeArrays(value)];
|
|
75693
|
+
} else {
|
|
75694
|
+
result[key] = [];
|
|
75593
75695
|
}
|
|
75594
|
-
|
|
75696
|
+
} else if (typeof value === "object") {
|
|
75697
|
+
result[key] = this.normalizeArrays(value);
|
|
75698
|
+
} else {
|
|
75699
|
+
result[key] = value;
|
|
75595
75700
|
}
|
|
75596
75701
|
}
|
|
75597
|
-
|
|
75702
|
+
return result;
|
|
75598
75703
|
}
|
|
75599
75704
|
}
|
|
75705
|
+
|
|
75706
|
+
// src/aws/index.ts
|
|
75707
|
+
init_rds();
|
|
75708
|
+
|
|
75600
75709
|
// src/aws/dynamodb.ts
|
|
75601
75710
|
init_client();
|
|
75602
75711
|
|
|
@@ -83204,6 +83313,16 @@ async function resolveSecrets(app, region) {
|
|
|
83204
83313
|
const sm = new SecretsManagerClient(region);
|
|
83205
83314
|
const out = {};
|
|
83206
83315
|
const entries = Array.isArray(app.secrets) ? app.secrets.map((name) => ({ envName: name.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g, "_"), secretId: name })) : Object.entries(app.secrets).map(([envName, secretId]) => ({ envName, secretId }));
|
|
83316
|
+
if (Array.isArray(app.secrets)) {
|
|
83317
|
+
const byName = new Map;
|
|
83318
|
+
for (const { envName, secretId } of entries)
|
|
83319
|
+
byName.set(envName, [...byName.get(envName) ?? [], secretId]);
|
|
83320
|
+
const clashes = [...byName.entries()].filter(([, ids]) => ids.length > 1);
|
|
83321
|
+
if (clashes.length) {
|
|
83322
|
+
const detail = clashes.map(([name, ids]) => `${name} ← ${ids.join(", ")}`).join("; ");
|
|
83323
|
+
throw new Error(`serverless secrets: multiple secrets map to the same env var (${detail}). Use the map form { ENV_NAME: 'secret/id' } to disambiguate.`);
|
|
83324
|
+
}
|
|
83325
|
+
}
|
|
83207
83326
|
for (const { envName, secretId } of entries) {
|
|
83208
83327
|
const value = await sm.getSecretValue({ SecretId: secretId });
|
|
83209
83328
|
const str = value.SecretString ?? "";
|
|
@@ -83489,6 +83608,8 @@ async function deployServerlessApp(config6, environment, opts = {}) {
|
|
|
83489
83608
|
LogType: "Tail"
|
|
83490
83609
|
});
|
|
83491
83610
|
if (res.FunctionError) {
|
|
83611
|
+
error("Deploy hook failed — the new build is ALREADY LIVE.");
|
|
83612
|
+
info(` Roll back with: cloud serverless:rollback --env ${environment}`);
|
|
83492
83613
|
throw new Error(`Deploy hook failed (${command}): ${res.Payload}`);
|
|
83493
83614
|
}
|
|
83494
83615
|
}
|