Skip to content

Commit

Permalink
Use provider object directly instead of wrapping it
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas11 committed Aug 16, 2023
1 parent 59cc1a8 commit 69859a4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions examples/callbackfunction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new pulumi.Config("aws");
const providerOpts = { provider: new aws.Provider("prov", { region: <aws.Region>config.require("envRegion") }) };
const provider = new aws.Provider("prov", {
region: <aws.Region>config.require("envRegion")
})
// const providerOpts = {
// provider: provider
// };

const role = new aws.iam.Role("role", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "lambda.amazonaws.com" }),
}, providerOpts);
}, { provider });

const policy = new aws.iam.Policy("policy", {
policy: {
Expand All @@ -36,29 +41,29 @@ const policy = new aws.iam.Policy("policy", {
const functions = [
new aws.lambda.CallbackFunction("a", {
callback: async () => ({ success: true }),
}, providerOpts),
}, { provider }),
new aws.lambda.CallbackFunction("b", {
role: role,
callback: async () => ({ success: true }),
}, providerOpts),
}, { provider }),
new aws.lambda.CallbackFunction("c", {
role: role.arn,
callback: async () => ({ success: true }),
}, providerOpts),
}, { provider }),
new aws.lambda.CallbackFunction("d", {
policies: [aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole],
callback: async () => ({ success: true }),
}, providerOpts),
}, { provider }),
new aws.lambda.CallbackFunction("e", {
callbackFactory: () => {
const ret = { success: true };
return async () => ret;
},
}, providerOpts),
// new aws.lambda.CallbackFunction("f", {
// policies: { one: policy.arn },
// callback: async () => ({ success: true }),
// }, providerOpts),
}, { provider }),
new aws.lambda.CallbackFunction("f", {
policies: { one: policy.arn },
callback: async () => ({ success: true }),
}, { provider }),
];

export const arns = functions.map(f => f.arn);

0 comments on commit 69859a4

Please sign in to comment.