Chr*_*ack 5 artifactory terraform
我希望从JFrog工件中提取一个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>}"
}
}
Run Code Online (Sandbox Code Playgroud)
我想做些相同的事情,但是要从需要身份验证的实例Artifactory中提取(看来HTTP模块无法做到),但是却找不到有关此操作的任何信息。有人知道这是否可能吗?如果是这样,怎么办?
任何帮助,将不胜感激。
谢谢,
克里斯
使用数据源artifactory_file获取sha256,然后对其进行base64编码,并将其传递给资源aws_lambda_function。
# Configure the Artifactory provider
# You may want to use SSM/SecretsManager data sources
# to configure the username and password
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" "default" {
function_name = "fantastic_service_name"
source_code_hash = filebase64sha256(data.artifactory_file.jar)
# ...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
487 次 |
| 最近记录: |