Skip to content

Instantly share code, notes, and snippets.

@squaremo
Created June 10, 2022 08:52
Show Gist options
  • Save squaremo/b7e7e078d06186b5a245500dd28cd2b2 to your computer and use it in GitHub Desktop.
Save squaremo/b7e7e078d06186b5a245500dd28cd2b2 to your computer and use it in GitHub Desktop.
Create a lambda from a string
"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