terraform

How to pass terraform outputs variables into ansible as vars_files?

走远了吗. 提交于 2020-06-08 04:15:32
问题 I am provisioning AWS infrastructure using terraform and want to pass variables such as aws_subnet_id and aws_security_id into ansible playbook using vars_file (don't know if there is any other way though). How can I do that? 回答1: terraform outputs are an option, or you can just use something like: provisioner "local-exec" { command = "ANSIBLE_HOST_KEY_CHECKING=\"False\" ansible-playbook -u ${var.ssh_user} --private-key=\"~/.ssh/id_rsa\" --extra-vars='{"aws_subnet_id": ${aws_terraform

How to pass terraform outputs variables into ansible as vars_files?

断了今生、忘了曾经 提交于 2020-06-08 04:14:18
问题 I am provisioning AWS infrastructure using terraform and want to pass variables such as aws_subnet_id and aws_security_id into ansible playbook using vars_file (don't know if there is any other way though). How can I do that? 回答1: terraform outputs are an option, or you can just use something like: provisioner "local-exec" { command = "ANSIBLE_HOST_KEY_CHECKING=\"False\" ansible-playbook -u ${var.ssh_user} --private-key=\"~/.ssh/id_rsa\" --extra-vars='{"aws_subnet_id": ${aws_terraform

Azure API management and App Function backend: Backend with id 'foo' could not be found

倖福魔咒の 提交于 2020-05-31 03:45:07
问题 In my company we have identical environments for our application: IT, ST, AT and PRD. We use Terraform to deploy our Azure resources, and are currently attempting to set up an API management solution which passes calls to a Function App backend. The set up is fairly simple, we have a series of APIs declared, and in their backend policies we declare this bit: <policies> <inbound> <set-backend-service id="apim-generated-policy" backend-id="function-at" /> </inbound> </policies> In IT/ST we have

Azure API management and App Function backend: Backend with id 'foo' could not be found

可紊 提交于 2020-05-31 03:44:13
问题 In my company we have identical environments for our application: IT, ST, AT and PRD. We use Terraform to deploy our Azure resources, and are currently attempting to set up an API management solution which passes calls to a Function App backend. The set up is fairly simple, we have a series of APIs declared, and in their backend policies we declare this bit: <policies> <inbound> <set-backend-service id="apim-generated-policy" backend-id="function-at" /> </inbound> </policies> In IT/ST we have

Terraform v0.12 Multi-line String EOF shell-style “here doc” syntax not been interpreted as before with v0.11

我们两清 提交于 2020-05-29 08:20:08
问题 Within Octopus Deploy I've setup a Terraform Apply Step using their Apply a Terraform template In my Terraform main.tf file I want to use a connection to run an remote-exec on a Amazon Linux EC2 instance in AWS resource "aws_instance" "nginx" { ami = "${var.aws_ami}" instance_type = "t2.nano" key_name = "${var.key_name}" connection { type = "ssh" user = "ec2-user" private_key = "${var.aws_key_path}" } provisioner "remote-exec" { inline = [ "sudo amazon-linux-extras install epel -y", "sudo yum

Terraform v0.12 Multi-line String EOF shell-style “here doc” syntax not been interpreted as before with v0.11

我是研究僧i 提交于 2020-05-29 08:19:05
问题 Within Octopus Deploy I've setup a Terraform Apply Step using their Apply a Terraform template In my Terraform main.tf file I want to use a connection to run an remote-exec on a Amazon Linux EC2 instance in AWS resource "aws_instance" "nginx" { ami = "${var.aws_ami}" instance_type = "t2.nano" key_name = "${var.key_name}" connection { type = "ssh" user = "ec2-user" private_key = "${var.aws_key_path}" } provisioner "remote-exec" { inline = [ "sudo amazon-linux-extras install epel -y", "sudo yum

Terraform depends_on with modules

為{幸葍}努か 提交于 2020-05-27 06:45:05
问题 I'm new at terraform and I created a custom azure policies on module structure. each policy represents a custom module. One of the modules that I have created is enabling diagnostics logs for any new azure resource created. but, I need a storage account for that. (before enabling the diagnostics settings how can I implement "depends_on"? or any other methods? I want to create first the storage account and then the module of diagnostics settings. on the main.tf (where calling all the other

I have a CSV and JSON data to parse the input values to the Terraform main file. Here I can able to parse the data using JSON but not with CSV

喜欢而已 提交于 2020-05-24 07:30:50
问题 I have a azure_subnet snippet to create resources like below. locals { csvlist = fileexists(var.csvfile) ? csvdecode(file(var.csvfile)) : [] subnets = length(var.subnets) > 0 ? var.subnets : local.csvlist } resource "azurerm_subnet" "subnet" { lifecycle { ignore_changes = [network_security_group_id] } count = length(local.subnets) > 0 && var.create ? length(local.subnets) : 0 name = local.subnets[count.index].name resource_group_name = var.resource_group virtual_network_name = var.vnet

Regex pattern to match terraform module code

独自空忆成欢 提交于 2020-05-17 07:43:11
问题 I am trying to use regex to match terraform module and add a comment to the beginning of the line. I am not able to use regex for the module block only. Note that some lines do repeat on other blocks like resource. The idea is to scan for module block and comment it. Any help will be greatly appreciated. Spent a lot of time bouncing ideas... module my module { name = myaws version = 1.0 source = terraform.mycompany.com tag = { cost = poc } } data "my file" "file-name-creation-data" { template

How do you output variables to Ansible? [duplicate]

ぃ、小莉子 提交于 2020-05-17 06:45:12
问题 This question already has answers here : How to pass terraform outputs variables into ansible as vars_files? (4 answers) Closed 7 days ago . I followed the answer here in this question and I have created a template file tf_ansible_vars_file.yml.tpl like below tf_share_location: "${share_location}" and a terra_render.tf like below # Define an Ansible var_file containing Terraform variable values data "template_file" "tf_ansible_vars_file" { template = "${file("/home/deployment_root/app4/tf