failure-lambda
Version:
Failure injection for AWS Lambda - chaos engineering made simple
520 lines (510 loc) • 15.4 kB
JavaScript
#!/usr/bin/env node
import {
ENV_KEY,
ENV_SECRET,
fromEnv
} from "./chunk-DLNZVS3G.js";
import {
customEndpointFunctions,
isIpAddress,
isValidHostLabel
} from "./chunk-762XZWE7.js";
import {
chain
} from "./chunk-LILC4PLL.js";
import {
ENV_PROFILE
} from "./chunk-52D4AVIU.js";
import {
CredentialsProviderError
} from "./chunk-M4AFYEP7.js";
// node_modules/@aws-sdk/credential-provider-node/dist-es/remoteProvider.js
var ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
var remoteProvider = async (init) => {
const { ENV_CMDS_FULL_URI, ENV_CMDS_RELATIVE_URI, fromContainerMetadata, fromInstanceMetadata } = await import("./dist-es-WWDFRCLL.js");
if (process.env[ENV_CMDS_RELATIVE_URI] || process.env[ENV_CMDS_FULL_URI]) {
init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromHttp/fromContainerMetadata");
const { fromHttp } = await import("./dist-es-U4WTKOAK.js");
return chain(fromHttp(init), fromContainerMetadata(init));
}
if (process.env[ENV_IMDS_DISABLED] && process.env[ENV_IMDS_DISABLED] !== "false") {
return async () => {
throw new CredentialsProviderError("EC2 Instance Metadata Service access disabled", { logger: init.logger });
};
}
init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromInstanceMetadata");
return fromInstanceMetadata(init);
};
// node_modules/@aws-sdk/credential-provider-node/dist-es/runtime/memoize-chain.js
function memoizeChain(providers, treatAsExpired) {
const chain2 = internalCreateChain(providers);
let activeLock;
let passiveLock;
let credentials;
const provider = async (options) => {
if (options?.forceRefresh) {
return await chain2(options);
}
if (credentials?.expiration) {
if (credentials?.expiration?.getTime() < Date.now()) {
credentials = void 0;
}
}
if (activeLock) {
await activeLock;
} else if (!credentials || treatAsExpired?.(credentials)) {
if (credentials) {
if (!passiveLock) {
passiveLock = chain2(options).then((c) => {
credentials = c;
}).finally(() => {
passiveLock = void 0;
});
}
} else {
activeLock = chain2(options).then((c) => {
credentials = c;
}).finally(() => {
activeLock = void 0;
});
return provider(options);
}
}
return credentials;
};
return provider;
}
var internalCreateChain = (providers) => async (awsIdentityProperties) => {
let lastProviderError;
for (const provider of providers) {
try {
return await provider(awsIdentityProperties);
} catch (err) {
lastProviderError = err;
if (err?.tryNextLink) {
continue;
}
throw err;
}
}
throw lastProviderError;
};
// node_modules/@aws-sdk/credential-provider-node/dist-es/defaultProvider.js
var multipleCredentialSourceWarningEmitted = false;
var defaultProvider = (init = {}) => memoizeChain([
async () => {
const profile = init.profile ?? process.env[ENV_PROFILE];
if (profile) {
const envStaticCredentialsAreSet = process.env[ENV_KEY] && process.env[ENV_SECRET];
if (envStaticCredentialsAreSet) {
if (!multipleCredentialSourceWarningEmitted) {
const warnFn = init.logger?.warn && init.logger?.constructor?.name !== "NoOpLogger" ? init.logger.warn.bind(init.logger) : console.warn;
warnFn(`-sdk/credential-provider-node - defaultProvider::fromEnv WARNING:
Multiple credential sources detected:
Both AWS_PROFILE and the pair AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY static credentials are set.
This SDK will proceed with the AWS_PROFILE value.
However, a future version may change this behavior to prefer the ENV static credentials.
Please ensure that your environment only sets either the AWS_PROFILE or the
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY pair.
`);
multipleCredentialSourceWarningEmitted = true;
}
}
throw new CredentialsProviderError("AWS_PROFILE is set, skipping fromEnv provider.", {
logger: init.logger,
tryNextLink: true
});
}
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromEnv");
return fromEnv(init)();
},
async (awsIdentityProperties) => {
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
throw new CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).", { logger: init.logger });
}
const { fromSSO } = await import("./dist-es-HZEEEMZH.js");
return fromSSO(init)(awsIdentityProperties);
},
async (awsIdentityProperties) => {
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromIni");
const { fromIni } = await import("./dist-es-KYWSYDLA.js");
return fromIni(init)(awsIdentityProperties);
},
async (awsIdentityProperties) => {
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromProcess");
const { fromProcess } = await import("./dist-es-DDAANG67.js");
return fromProcess(init)(awsIdentityProperties);
},
async (awsIdentityProperties) => {
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromTokenFile");
const { fromTokenFile } = await import("./dist-es-LJMJITDD.js");
return fromTokenFile(init)(awsIdentityProperties);
},
async () => {
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::remoteProvider");
return (await remoteProvider(init))();
},
async () => {
throw new CredentialsProviderError("Could not load credentials from any providers", {
tryNextLink: false,
logger: init.logger
});
}
], credentialsTreatedAsExpired);
var credentialsTreatedAsExpired = (credentials) => credentials?.expiration !== void 0 && credentials.expiration.getTime() - Date.now() < 3e5;
// node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/isVirtualHostableS3Bucket.js
var isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
if (allowSubDomains) {
for (const label of value.split(".")) {
if (!isVirtualHostableS3Bucket(label)) {
return false;
}
}
return true;
}
if (!isValidHostLabel(value)) {
return false;
}
if (value.length < 3 || value.length > 63) {
return false;
}
if (value !== value.toLowerCase()) {
return false;
}
if (isIpAddress(value)) {
return false;
}
return true;
};
// node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/parseArn.js
var ARN_DELIMITER = ":";
var RESOURCE_DELIMITER = "/";
var parseArn = (value) => {
const segments = value.split(ARN_DELIMITER);
if (segments.length < 6)
return null;
const [arn, partition2, service, region, accountId, ...resourcePath] = segments;
if (arn !== "arn" || partition2 === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "")
return null;
const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();
return {
partition: partition2,
service,
region,
accountId,
resourceId
};
};
// node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/partitions.json
var partitions_default = {
partitions: [{
id: "aws",
outputs: {
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
implicitGlobalRegion: "us-east-1",
name: "aws",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$",
regions: {
"af-south-1": {
description: "Africa (Cape Town)"
},
"ap-east-1": {
description: "Asia Pacific (Hong Kong)"
},
"ap-east-2": {
description: "Asia Pacific (Taipei)"
},
"ap-northeast-1": {
description: "Asia Pacific (Tokyo)"
},
"ap-northeast-2": {
description: "Asia Pacific (Seoul)"
},
"ap-northeast-3": {
description: "Asia Pacific (Osaka)"
},
"ap-south-1": {
description: "Asia Pacific (Mumbai)"
},
"ap-south-2": {
description: "Asia Pacific (Hyderabad)"
},
"ap-southeast-1": {
description: "Asia Pacific (Singapore)"
},
"ap-southeast-2": {
description: "Asia Pacific (Sydney)"
},
"ap-southeast-3": {
description: "Asia Pacific (Jakarta)"
},
"ap-southeast-4": {
description: "Asia Pacific (Melbourne)"
},
"ap-southeast-5": {
description: "Asia Pacific (Malaysia)"
},
"ap-southeast-6": {
description: "Asia Pacific (New Zealand)"
},
"ap-southeast-7": {
description: "Asia Pacific (Thailand)"
},
"aws-global": {
description: "aws global region"
},
"ca-central-1": {
description: "Canada (Central)"
},
"ca-west-1": {
description: "Canada West (Calgary)"
},
"eu-central-1": {
description: "Europe (Frankfurt)"
},
"eu-central-2": {
description: "Europe (Zurich)"
},
"eu-north-1": {
description: "Europe (Stockholm)"
},
"eu-south-1": {
description: "Europe (Milan)"
},
"eu-south-2": {
description: "Europe (Spain)"
},
"eu-west-1": {
description: "Europe (Ireland)"
},
"eu-west-2": {
description: "Europe (London)"
},
"eu-west-3": {
description: "Europe (Paris)"
},
"il-central-1": {
description: "Israel (Tel Aviv)"
},
"me-central-1": {
description: "Middle East (UAE)"
},
"me-south-1": {
description: "Middle East (Bahrain)"
},
"mx-central-1": {
description: "Mexico (Central)"
},
"sa-east-1": {
description: "South America (Sao Paulo)"
},
"us-east-1": {
description: "US East (N. Virginia)"
},
"us-east-2": {
description: "US East (Ohio)"
},
"us-west-1": {
description: "US West (N. California)"
},
"us-west-2": {
description: "US West (Oregon)"
}
}
}, {
id: "aws-cn",
outputs: {
dnsSuffix: "amazonaws.com.cn",
dualStackDnsSuffix: "api.amazonwebservices.com.cn",
implicitGlobalRegion: "cn-northwest-1",
name: "aws-cn",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^cn\\-\\w+\\-\\d+$",
regions: {
"aws-cn-global": {
description: "aws-cn global region"
},
"cn-north-1": {
description: "China (Beijing)"
},
"cn-northwest-1": {
description: "China (Ningxia)"
}
}
}, {
id: "aws-eusc",
outputs: {
dnsSuffix: "amazonaws.eu",
dualStackDnsSuffix: "api.amazonwebservices.eu",
implicitGlobalRegion: "eusc-de-east-1",
name: "aws-eusc",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^eusc\\-(de)\\-\\w+\\-\\d+$",
regions: {
"eusc-de-east-1": {
description: "AWS European Sovereign Cloud (Germany)"
}
}
}, {
id: "aws-iso",
outputs: {
dnsSuffix: "c2s.ic.gov",
dualStackDnsSuffix: "api.aws.ic.gov",
implicitGlobalRegion: "us-iso-east-1",
name: "aws-iso",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^us\\-iso\\-\\w+\\-\\d+$",
regions: {
"aws-iso-global": {
description: "aws-iso global region"
},
"us-iso-east-1": {
description: "US ISO East"
},
"us-iso-west-1": {
description: "US ISO WEST"
}
}
}, {
id: "aws-iso-b",
outputs: {
dnsSuffix: "sc2s.sgov.gov",
dualStackDnsSuffix: "api.aws.scloud",
implicitGlobalRegion: "us-isob-east-1",
name: "aws-iso-b",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^us\\-isob\\-\\w+\\-\\d+$",
regions: {
"aws-iso-b-global": {
description: "aws-iso-b global region"
},
"us-isob-east-1": {
description: "US ISOB East (Ohio)"
},
"us-isob-west-1": {
description: "US ISOB West"
}
}
}, {
id: "aws-iso-e",
outputs: {
dnsSuffix: "cloud.adc-e.uk",
dualStackDnsSuffix: "api.cloud-aws.adc-e.uk",
implicitGlobalRegion: "eu-isoe-west-1",
name: "aws-iso-e",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^eu\\-isoe\\-\\w+\\-\\d+$",
regions: {
"aws-iso-e-global": {
description: "aws-iso-e global region"
},
"eu-isoe-west-1": {
description: "EU ISOE West"
}
}
}, {
id: "aws-iso-f",
outputs: {
dnsSuffix: "csp.hci.ic.gov",
dualStackDnsSuffix: "api.aws.hci.ic.gov",
implicitGlobalRegion: "us-isof-south-1",
name: "aws-iso-f",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^us\\-isof\\-\\w+\\-\\d+$",
regions: {
"aws-iso-f-global": {
description: "aws-iso-f global region"
},
"us-isof-east-1": {
description: "US ISOF EAST"
},
"us-isof-south-1": {
description: "US ISOF SOUTH"
}
}
}, {
id: "aws-us-gov",
outputs: {
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
implicitGlobalRegion: "us-gov-west-1",
name: "aws-us-gov",
supportsDualStack: true,
supportsFIPS: true
},
regionRegex: "^us\\-gov\\-\\w+\\-\\d+$",
regions: {
"aws-us-gov-global": {
description: "aws-us-gov global region"
},
"us-gov-east-1": {
description: "AWS GovCloud (US-East)"
},
"us-gov-west-1": {
description: "AWS GovCloud (US-West)"
}
}
}],
version: "1.1"
};
// node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/partition.js
var selectedPartitionsInfo = partitions_default;
var partition = (value) => {
const { partitions } = selectedPartitionsInfo;
for (const partition2 of partitions) {
const { regions, outputs } = partition2;
for (const [region, regionData] of Object.entries(regions)) {
if (region === value) {
return {
...outputs,
...regionData
};
}
}
}
for (const partition2 of partitions) {
const { regionRegex, outputs } = partition2;
if (new RegExp(regionRegex).test(value)) {
return {
...outputs
};
}
}
const DEFAULT_PARTITION = partitions.find((partition2) => partition2.id === "aws");
if (!DEFAULT_PARTITION) {
throw new Error("Provided region was not found in the partition array or regex, and default partition with id 'aws' doesn't exist.");
}
return {
...DEFAULT_PARTITION.outputs
};
};
// node_modules/@aws-sdk/util-endpoints/dist-es/aws.js
var awsEndpointFunctions = {
isVirtualHostableS3Bucket,
parseArn,
partition
};
customEndpointFunctions.aws = awsEndpointFunctions;
export {
defaultProvider,
awsEndpointFunctions
};
//# sourceMappingURL=chunk-5O7KUBNU.js.map