https://pulumi.com logo
b

broad-dog-22463

01/20/2020, 10:50 AM
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

stocky-island-3676

01/20/2020, 10:55 AM
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

future-barista-68134

01/21/2020, 2:41 PM
is this in the pulumi/examples repo? If not, it should be!
Great example
b

broad-dog-22463

01/21/2020, 4:37 PM
@future-barista-68134 it will be when I finish the code I’m writing :)
🙌 1