terraform

How to get AWS Lambda ARN using Terraform?

半城伤御伤魂 提交于 2021-01-28 07:57:42
问题 I am trying to define a terraform output block that returns the ARN of a Lambda function. The Lambda is defined in a sub-module. According to the documentation it seems like the lambda should just have an ARN attribute already: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_function#arn Using that as a source I thought I should be able to do the following: output "lambda_arn" { value = module.aws_lambda_function.arn } This generates the following error:

Relative path in local-exec

巧了我就是萌 提交于 2021-01-28 06:27:07
问题 I'm trying to reference a local script inside a local-exec provisioner. The script is located several levels above the module directory. Using ${path.module}/../../scripts/somescript.ps1 generates a path not found error. Moving the scripts directory under the modules directory solves the problem but unfortunately is not a valid option in my case. Working scenario: ${path.module}/scripts/somescript.ps1 I didn't see anywhere that it's a TF limitation or a bug so, any help is highly appreciated.

Terraform for_each use case

梦想的初衷 提交于 2021-01-28 05:44:02
问题 I am creating a bunch of Route 53 resolver rules in each region and this works great with for_each loop: resource "aws_route53_resolver_rule" "resolver-rule" { for_each = var.resolver-rules domain_name = each.value.domain-name name = format("core-%s", each.value.domain-label) rule_type = "FORWARD" resolver_endpoint_id = aws_route53_resolver_endpoint.outbound-endpoint.id target_ip { ip = each.value.forwarder1 } target_ip { ip = each.value.forwarder2 } tags = merge(var.tags, map("Name", format(

Terraform: command “Powershell.exe” produced invalid JSON: unexpected end of JSON input

≡放荡痞女 提交于 2021-01-28 05:40:21
问题 I am trying to use Terraform's external provider to run a PowerShell script. I am not able to pass parameters to the script from Terraform. I am using the following code to run the script: variable "file_path" { type = "string" description = "Enter the powershell file path" default = "../../Services/azurerm_iam_role/Powershell_Scripts/test.ps1" } data "external" "powershell_test" { program = ["Powershell.exe", "${var.file_path}"] query = { foo = "asdf" bar = "Hardcoded" } } The following is

KubeVela:标准化的云原生平台构建引擎

匆匆过客 提交于 2021-01-28 05:22:31
作者 | 孙健波(天元) 来源| 阿里巴巴云原生公众号 本文由“GO 开源说”第三期 KubeVela 直播内容修改整理而成,视频内容较长,本文内容有所删减和重构。 点击查看视频 KubeVela 的背景 KubeVela 是一个基于 Go 语言开发的云原生平台级开源项目,这个项目是 去年 11 月中旬正式发布 的。虽然发布到现在不足两个月时间,但是 KubeVela 作为"阿里巴巴统一云原生应用平台内核”背后的核心依赖,其实已经在阿里多个产品背后运行了比较长的一段时间,我本人目前也在大量参与这些产品和项目的内核建设工作。 KubeVela: https://github.com/oam-dev/kubevela 这套内核系统诞生自 2019 年年底阿里云联合微软共同推出的 Open Application Model(简称 OAM )模型基于 Kubernetes 的实现,在不断演进和迭代中融合了大量来自开源社区(尤其是微软、字节跳动、第四范式、腾讯和满帮集团的社区参与者们)的反馈与贡献,最终在 2020 年 KubeCon 北美峰会 上以 “KubeVela” 的名字正式与开源社区见面。KubeVela 项目在官宣后得到了整个云原生生态的持续关注,在发布后的第四天就登上了 Go 语言的开源趋势榜榜首。 图 1 KubeVela 的 GitHub Star 快速增长

Are terraform “loops” useless? Or am I missing something?

守給你的承諾、 提交于 2021-01-28 05:08:55
问题 I wrote some configuration today that uses "loops", but only afterwards I wondered if this is the right path to go, since terraform keeps the resources in the state file as a list/array. Consider the following configuration: locals { users_list = [ "ab", "cd", "ef" ] } resource "aws_iam_user" "users" { count = "${length(local.users_list)}" name = "${local.users_list["${count.index}"]}" path = "/" } Running 'terraform apply' will create the users, and create the following resources in the

Use a map of lists of maps in resource creation

眉间皱痕 提交于 2021-01-28 05:05:13
问题 I want to be able to create multiple R53 records, using the following format defined in TF Vars: custom_zone_records = { "demo.a.com" = [ {"*.b" = {type: "CNAME", records: ["d.com"]}}, {"*.c" = {type: "CNAME", records: ["d.com"]}} ] } Using the record as an example, it should create the R53 record of: Name: *.b.demo.a.com Type: CNAME Records: ["d.com"] The input variable is defined as: variable "custom_zone_records" { description = "A map of maps for custom zone records" type = map(list(map

Use a map of lists of maps in resource creation

ⅰ亾dé卋堺 提交于 2021-01-28 05:03:49
问题 I want to be able to create multiple R53 records, using the following format defined in TF Vars: custom_zone_records = { "demo.a.com" = [ {"*.b" = {type: "CNAME", records: ["d.com"]}}, {"*.c" = {type: "CNAME", records: ["d.com"]}} ] } Using the record as an example, it should create the R53 record of: Name: *.b.demo.a.com Type: CNAME Records: ["d.com"] The input variable is defined as: variable "custom_zone_records" { description = "A map of maps for custom zone records" type = map(list(map

Quit condition on Terraform blueprint

泄露秘密 提交于 2021-01-28 03:52:50
问题 I want to have a terraform blueprint that quits given a certain condition at the top. If the var.available is set to false, I want the blueprint to stop everything and throw an error. What is the syntax for this? I cannot find it in the doc files anywhere. Does this functionality even exist in terraform yet? Note: this code is in a .tf blueprint file My code: available_ports = "${var.available ? 1 : quit_here}" 回答1: There is a workaround to stop the Terraform script from executing based on a

Quit condition on Terraform blueprint

落花浮王杯 提交于 2021-01-27 23:33:33
问题 I want to have a terraform blueprint that quits given a certain condition at the top. If the var.available is set to false, I want the blueprint to stop everything and throw an error. What is the syntax for this? I cannot find it in the doc files anywhere. Does this functionality even exist in terraform yet? Note: this code is in a .tf blueprint file My code: available_ports = "${var.available ? 1 : quit_here}" 回答1: There is a workaround to stop the Terraform script from executing based on a