Created
June 10, 2022 08:52
-
-
Save squaremo/b7e7e078d06186b5a245500dd28cd2b2 to your computer and use it in GitHub Desktop.
Create a lambda from a string
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
"use strict"; | |
const pulumi = require("@pulumi/pulumi"); | |
const asset = require('@pulumi/pulumi/asset'); | |
const aws = require("@pulumi/aws"); | |
const script = new asset.StringAsset(`#!/bin/sh | |
echo "file executed!" | |
`); | |
const archive = new asset.AssetArchive({ | |
"handler": script, | |
}); | |
const iamForLambda = new aws.iam.Role("iamForLambda", {assumeRolePolicy: `{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" | |
} | |
] | |
} | |
`}); | |
const testLambda = new aws.lambda.Function("testLambda", { | |
code: archive, | |
role: iamForLambda.arn, | |
handler: "handler", | |
runtime: "go1.x", | |
}); | |
exports.lambda = testLambda.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment