Just thought I'd throw this piece of code out ther...
# general
b
Just thought I'd throw this piece of code out there - it's for multiple region deployments of resources in Pulumi - this specific example is for Lambdas
Copy code
const providers: {[key: string]: aws.Provider} = {
    "us-east-1": new aws.Provider("us-east-1", {region: "us-east-1"}),
    "us-east-2": new aws.Provider("us-east-2", {region: "us-east-2"}),
    "us-west-2": new aws.Provider("us-west-2", {region: "us-west-2"})
};

for (const providerKey of Object.keys(providers)) {
    const provider = providers[providerKey];

    const lambda = new aws.lambda.Function(`my-lambda-function-${providerKey}`, {
        name: "lambda-for-account-cleanup",
        runtime: aws.lambda.Go1dxRuntime,
        timeout: 900,
        role: iamRoleArn,
        handler: "main",
        code: new pulumi.asset.FileArchive("../deployment.zip"),
        environment: {
            variables: {
                "DESTROY_ENABLED": "false"
            }
        },
        tags: {
            "Owner": "Stack72",
            "Purpose": "AccountCleanup",
        }
    }, {provider: provider});
}
đź’Ż 1
đź‘Ť 1
s
Nice. With a “code snippet”, it would be even better to read. Syntax highlighting included 🙂 (Just want to nudge into good practice 🙂 .)
@broad-dog-22463
f
is this in the pulumi/examples repo? If not, it should be!
Great example
b
@future-barista-68134 it will be when I finish the code I’m writing :)
🙌 1