-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.tf
More file actions
39 lines (33 loc) · 1.2 KB
/
main.tf
File metadata and controls
39 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
locals {
has_ssh_key = var.ssh_key_secret_arn != null || var.ssh_key_secret_name != null
#TODO: use different templates for different linux versions
data = templatefile("${path.module}/component-al2.yml.tpl", {
additional_pkgs = var.additional_packages
additional_pip_pkgs = var.additional_pip_packages
ansible_pyenv_path = var.ansible_pyenv_path
description = var.description
name = var.name
python_version = var.python_version
ssh_key_name = try(data.aws_secretsmanager_secret.ssh_key[0].name, null)
})
}
data "aws_secretsmanager_secret" "ssh_key" {
count = local.has_ssh_key ? 1 : 0
arn = var.ssh_key_secret_arn
name = var.ssh_key_secret_name
}
resource "aws_imagebuilder_component" "this" {
name = var.name
version = var.component_version
change_description = var.change_description
data = var.data_uri == null ? local.data : ""
description = var.description
kms_key_id = var.kms_key_id
platform = var.platform
supported_os_versions = var.supported_os_versions
uri = var.data_uri
tags = merge(
var.tags,
{ Name : "${var.name}" }
)
}