-
-
Save mominosin/59e991cac7e2e83c2538facce0098d29 to your computer and use it in GitHub Desktop.
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
variable release_tag { | |
default = "aws-dd-forwarder-3.12.0" | |
} | |
variable lambda_role {} | |
locals { | |
ddf_dl_path = format("%s/%s.zip", path.cwd, var.release_tag) | |
} | |
provider github { | |
anonymous = true | |
individual = true | |
} | |
data github_release dd_forwarder { | |
repository = "datadog-serverless-functions" | |
owner = "DataDog" | |
retrieve_by = "tag" | |
release_tag = var.release_tag | |
} | |
data http dd_forwarder { | |
url = data.github_release.dd_forwarder.asserts_url | |
request_headers = { | |
Accept = "application/json" | |
} | |
} | |
resource null_resource dd_forwarder { | |
triggers = { | |
timestamp = timestamp() | |
} | |
provisioner local-exec { | |
command = "wget $dl_url -O $dl_path" | |
environment = { | |
dl_url = jsondecode(data.http.dd_forwarder.body)[0]["browser_download_url"] | |
dl_path = local.ddf_dl_path | |
} | |
} | |
} | |
provider aws { | |
region = "ap-northeast-1" | |
} | |
resource aws_lambda_function dd_forwarder { | |
filename = local.ddf_dl_path | |
function_name = "lambda_function_name" | |
handler = "lambda_function.lambda_handler" | |
role = var.lambda_role | |
runtime = "python3.7" | |
depends_on = [ null_resource.dd_forwarder ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment