-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch lambda to allow imports #3420
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f41b226
repro issue
VenelinMartinov ba1e43a
patch upstream lambda
VenelinMartinov 8a1ce3c
add additional test
VenelinMartinov e168c2a
update test
VenelinMartinov 175e56c
add test for validating pulumi import lambdas
VenelinMartinov 616fb12
update patch
VenelinMartinov a7bc748
go mod tidy
VenelinMartinov 9eefc43
Merge branch 'master' into vvm/repro_lambda_import_issue
VenelinMartinov e47cc96
rename patch
VenelinMartinov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/bin/ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: lambda-import-ts | ||
runtime: nodejs | ||
description: A minimal AWS TypeScript Pulumi program | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: aws-typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as archive from "@pulumi/archive"; | ||
import * as aws from "@pulumi/aws"; | ||
|
||
const config = new pulumi.Config(); | ||
const imported_lambda_name = config.get("lambda_name"); | ||
const imported_lambda_role = config.get("lambda_role"); | ||
|
||
const runtime = config.get("runtime"); | ||
|
||
const assumeRole = aws.iam.getPolicyDocument({ | ||
statements: [{ | ||
effect: "Allow", | ||
principals: [{ | ||
type: "Service", | ||
identifiers: ["lambda.amazonaws.com"], | ||
}], | ||
actions: ["sts:AssumeRole"], | ||
}], | ||
}); | ||
const iamForLambda = new aws.iam.Role("iamForLambda", {assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json)}); | ||
const lambda = archive.getFile({ | ||
type: "zip", | ||
sourceFile: "lambda.js", | ||
outputPath: "lambda_function_payload.zip", | ||
}); | ||
|
||
const testLambda = new aws.lambda.Function("testLambda", { | ||
name: imported_lambda_name, | ||
code: imported_lambda_name ? undefined : new pulumi.asset.FileArchive("lambda_function_payload.zip"), | ||
role: imported_lambda_role || iamForLambda.arn, | ||
handler: "index.test", | ||
runtime: runtime || "nodejs18.x", | ||
environment: { | ||
variables: { | ||
foo: "bar", | ||
}, | ||
}, | ||
}, imported_lambda_name ? { | ||
import: imported_lambda_name, ignoreChanges: ["code", "filename", "s3_bucket", "source_code_hash", "image_uri"] | ||
} : undefined); | ||
|
||
export const lambda_name = testLambda.name; | ||
export const lambda_role = testLambda.role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("hi") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "lambda-import-ts", | ||
"main": "index.ts", | ||
"devDependencies": { | ||
"@types/node": "^18" | ||
}, | ||
"dependencies": { | ||
"@pulumi/pulumi": "^3.0.0", | ||
"@pulumi/aws": "5.28.0", | ||
"@pulumi/awsx": "^2.0.2", | ||
"@pulumi/archive": "^0.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: no-code-lambda | ||
runtime: yaml | ||
description: A minimal AWS Pulumi YAML program | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: aws-yaml | ||
resources: | ||
iamForLambda: | ||
type: aws:iam:Role | ||
properties: | ||
assumeRolePolicy: ${assumeRole.json} | ||
testLambda: | ||
type: aws:lambda:Function | ||
properties: | ||
role: ${iamForLambda.arn} | ||
handler: index.test | ||
runtime: nodejs18.x | ||
environment: | ||
variables: | ||
foo: bar | ||
variables: | ||
assumeRole: | ||
fn::invoke: | ||
Function: aws:iam:getPolicyDocument | ||
Arguments: | ||
statements: | ||
- effect: Allow | ||
principals: | ||
- type: Service | ||
identifiers: | ||
- lambda.amazonaws.com | ||
actions: | ||
- sts:AssumeRole |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no asserts here are we sure this is a strong test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The framework has the asserts by default: https://github.com/pulumi/providertest/blob/dc14d64784583753791733c6ac090d972d1ec746/pulumitest/up.go#L18
I've also verified that the test fails without the patch.