【发布时间】:2021-09-21 04:30:22
【问题描述】:
我有一个script.yml,其中包含许多我想传递给我的 terraform-aws-imagebuilder-component-shell 模块的命令。需要此 yaml 文件来强化我的 ec2-image-builder 管道。我可以从 aws 控制台图像生成器轻松创建管道的这个组件,但我正在尝试对我从这里获得的整个项目进行 terraform --> https://github.com/rhythmictech/terraform-aws-imagebuilder-component-shell。我是 Terraform 的新手,根据我的研究,我需要将我的 yaml 文件中的命令列表注入到我的 variables.tf 中。请参阅下面的代码:
script.yml(文件比这个长,只是给你一个想法)
schemaVersion: 1.0
phases:
- name: build
steps:
- name: CISBenchmarkHardening
action: ExecuteBash
inputs:
commands:
# §1.1
- echo "install cramfs /bin/true" > /etc/modprobe.d/cramfs.conf
- echo "install vfat /bin/true" > /etc/modprobe.d/vfat.conf
- echo "install squashfs /bin/true" > /etc/modprobe.d/squashfs.conf
- echo "install udf /bin/true" > /etc/modprobe.d/udf.conf
- echo "install usb-storage /bin/true" > /etc/modprobe.d/usb-storage.conf
# §1.2
- echo "localpkg_gpgcheck=1" >> /etc/yum.conf
variables.tf
variable "change_description" {
default = null
description = "description of changes since last version"
type = string
}
variable "cloudformation_timeout" {
default = 10
description = "How long to wait (in minutes) for CFN to apply before giving up"
type = number
}
variable "commands" {
default = ["command 1"] # need to update
description = "List of strings. Each string is a shell command"
type = list(string)
}
variable "component_version" {
default = "1.0.0"
description = "Version of the component"
type = string
}
variable "create" {
default = true
description = "A flag to disable creation of the component"
type = bool
}
variable "data_uri" {
default = null
description = "Use this to override the component document with one at a particular URL endpoint"
type = string
}
variable "description" {
default = null
description = "description of component"
type = string
}
variable "kms_key_id" {
default = null
description = "KMS key to use for encryption"
type = string
}
variable "name" {
default = "testcomponent"
description = "name to use for component"
type = string
}
variable "phase" {
default = "build"
description = "The Image Builder phase this component is in, either 'build' or 'test'."
type = string
}
# TODO: add validation
variable "platform" {
default = "Linux"
description = "platform of component (Linux or Windows)"
type = string
}
variable "tags" {
default = {}
description = "map of tags to use for CFN stack and component"
type = map(string)
}
您可以看到我的script.yml 文件中的命令很多,我想知道将这些命令传递给我的variables.tf 的最聪明的方法,或者最好让我的script.yml 坐在我的回购中的某个地方并通过它作为 command 在我的 variables.tf 中的输入。希望这是有道理的:(!!如果我遗漏了什么,请告诉我,我将不胜感激任何指针..祝福
【问题讨论】:
标签: amazon-web-services terraform