Skip to content

Commit

Permalink
upgrade lambda to node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
vikasperi committed Nov 25, 2024
1 parent 200bd76 commit 8d40ebd
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 73 deletions.
140 changes: 70 additions & 70 deletions libs/pulumi-lambda/src/lib/lambda-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,35 @@ export class LambdaFunction extends pulumi.ComponentResource {
},
opts?:
| (pulumi.ComponentResourceOptions & {
/**
* Some versions of pulumi and/or aws-sdk are unable to delete log groups D:<
* This provides a way to alias them, so they don't need to be deleted &
* recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
logGroupAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.iam.Role resource to be migrated into this module,
* without module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
executionRoleAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.iam.RolePolicyAttachment resource to be migrated
* into this module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
rolePolicyAttachmentAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.lambda.Function resource to be migrated
* into this module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
functionAliases?: pulumi.ComponentResourceOptions['aliases']
})
/**
* Some versions of pulumi and/or aws-sdk are unable to delete log groups D:<
* This provides a way to alias them, so they don't need to be deleted &
* recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
logGroupAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.iam.Role resource to be migrated into this module,
* without module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
executionRoleAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.iam.RolePolicyAttachment resource to be migrated
* into this module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
rolePolicyAttachmentAliases?: pulumi.ComponentResourceOptions['aliases']

/**
* Allow an existing aws.lambda.Function resource to be migrated
* into this module without being deleted & recreated. More info:
* https://www.pulumi.com/docs/intro/concepts/resources/#aliases
*/
functionAliases?: pulumi.ComponentResourceOptions['aliases']
})
| undefined,
) {
super('wanews:lambda', name, {}, opts)
Expand Down Expand Up @@ -111,47 +111,47 @@ export class LambdaFunction extends pulumi.ComponentResource {

this.executionRole = args.executionRoleName
? pulumi
.output(args.executionRoleName)
.apply((role) =>
aws.iam.getRole(
{ name: role },
{
parent: this,
async: true,
},
),
)
.apply((result) =>
aws.iam.Role.get(result.name, result.id, undefined, {
parent: this,
}),
)
.output(args.executionRoleName)
.apply((role) =>
aws.iam.getRole(
{ name: role },
{
parent: this,
async: true,
},
),
)
.apply((result) =>
aws.iam.Role.get(result.name, result.id, undefined, {
parent: this,
}),
)
: args.executionRole
? pulumi.output(args.executionRole)
: pulumi.output(
new aws.iam.Role(
roleName,
{
assumeRolePolicy: {
Version: '2012-10-17',
Statement: [
{
Action: 'sts:AssumeRole',
Principal: {
Service: 'lambda.amazonaws.com',
},
Effect: 'Allow',
},
],
},
tags: args.getTags(name),
},
{
parent: this,
aliases: opts?.executionRoleAliases,
},
),
)
? pulumi.output(args.executionRole)
: pulumi.output(
new aws.iam.Role(
roleName,
{
assumeRolePolicy: {
Version: '2012-10-17',
Statement: [
{
Action: 'sts:AssumeRole',
Principal: {
Service: 'lambda.amazonaws.com',
},
Effect: 'Allow',
},
],
},
tags: args.getTags(name),
},
{
parent: this,
aliases: opts?.executionRoleAliases,
},
),
)

new aws.iam.RolePolicyAttachment(
`${name}-attach-execution-policy`,
Expand All @@ -166,7 +166,7 @@ export class LambdaFunction extends pulumi.ComponentResource {
name,
{
name,
runtime: 'nodejs14.x',
runtime: 'nodejs16.x',
role: this.executionRole.arn.apply(async (arn) => {
if (args.delayLambdaDeployment) {
console.log('waiting for IAM changes to propagate')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@nrwl/jest": "13.10.2",
"@nrwl/linter": "13.10.2",
"@nrwl/workspace": "13.10.2",
"@pulumi/aws": "^5.1.3",
"@pulumi/aws": "^5.43.0",
"@pulumi/pagerduty": "^3.4.0",
"@pulumi/pulumi": "^3.29.1",
"@pulumi/random": "^4.4.2",
Expand Down
17 changes: 15 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d40ebd

Please # to comment.