我希望从JFrog artifactory中提取一个jar文件,并将其用作使用Terraform部署到AWS Lambda函数的源代码。我目前正在使用下面的代码从S3存储桶中提取:
data "aws_s3_bucket_object" "function-lambda-file-hash" {
bucket = "<MYBUCKET>
key = "<MYKEY.sha1>"
tags {
Name = "${var.<MYTAG>}"
}
}
# Create the Lambda function itself
resource "aws_lambda_function" "function-lambda" {
function_name = "function-lambda"
handler = "com.example.MyFunction::handleRequest"
runtime = "java8"
s3_bucket="<MYBUCKET>"
s3_key="<MYKEY.jar>"
source_code_hash = "${data.aws_s3_bucket_object.function-lambda-file-hash.body}"
role = "${aws_iam_role.function-lambda-exec-role.arn}"
timeout = 30
memory_size = 256
tags {
Name = "${var.<MYTAG>}"
}
}
我想做一些相同的事情但是从Artifactory中提取,这是一个需要身份验证的实例(似乎HTTP模块似乎无法做到),而是找不到任何关于这样做的信息。有谁知道这是否可能?如果是这样,怎么样?
任何帮助都将不胜感激。
谢谢,
克里斯
答案 0 :(得分:0)
使用数据源artifactory_file
获取sha256,然后base64编码,传递给aws_lambda_function
资源。
# Configure the Artifactory provider
provider "artifactory" {
url = "${var.artifactory_url}/artifactory"
username = var.artifactory_username
password = var.artifactory_password
}
data "artifactory_file" "jar" {
repository = "repo-key"
path = "/path/to/the/artifact.jar"
output_path = "artifact.jar"
}
resource "aws_lambda_function" "function-lambda" {
function_name = "function-lambda"
source_code_hash = base64encode(data.artifactory_file.jar.sha256)
# ...
}