Skip to content

Instantly share code, notes, and snippets.

@kylegalbraith
Created March 21, 2018 19:32
Show Gist options
  • Save kylegalbraith/bab98a76a5fef597d23eb730331e72b9 to your computer and use it in GitHub Desktop.
Save kylegalbraith/bab98a76a5fef597d23eb730331e72b9 to your computer and use it in GitHub Desktop.
terraform 0.11.4 destroy
variable "region" { default = "us-west-2" }
variable "packagePath" { default = "code\\package.zip" }
variable "packageName" { default = "package.zip" }
locals {
packageFile = "${file("${path.module}\\${var.packagePath}")}"
}
provider "aws" {
region = "${var.region}"
}
resource "aws_s3_bucket" "deployment-bucket" {
bucket = "test-deployment-bucket"
acl = "private"
}
resource "aws_s3_bucket_object" "deployment-package" {
bucket = "${aws_s3_bucket.deployment-bucket.id}"
key = "${var.packageName}"
source = "${var.packagePath}"
etag = "${md5("${local.packageFile}")}"
}
resource "aws_iam_role" "lambda-role" {
name = "test-lambda-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_lambda_function" "shifting-lambda" {
function_name = "shifting-test"
role = "${aws_iam_role.lambda-role.arn}"
s3_bucket = "${aws_s3_bucket.deployment-bucket.id}"
s3_key = "${aws_s3_bucket_object.deployment-package.id}"
s3_object_version = "${aws_s3_bucket_object.deployment-package.version_id}"
publish = true
handler = "index.handler"
runtime = "nodejs6.10"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment