Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all 11395 articles
Browse latest View live

Bash Script Terraform Workspace List

$
0
0

@fdmsantos wrote:

When I run terraform workspace list I got:
❯ terraform workspace list

  • default
    test

But if I run like this echo $(terraform workspace list) I also got the list of files in the current folder:

main.tf api.tf modules README.md terraform.tfvars.example test.tfvars variables.tf default test

Why does this happen?

Thanks for the support.

Posts: 3

Participants: 2

Read full topic


Structuring Terraform

$
0
0

@mattmo-xyz wrote:

Hello everyone,

This may be an extremely basic question but I’m currently unable to find a clear answer - how should i go about structuring my Terraform code? In my example i’m creating a VPC, EC2 instance, SSH Key, ELB, and SGs.

Initially I created these within a single root directory but I can see how this will get messy quickly especially as more services are added. I’ve started spliiting it off with the following:

├── environments
│ ├── dev
│ ├── prod
│ └── uat
├── main.tf
├── modules
│ ├── compute
│ │ └── main.tf
│ ├── keys
│ │ ├── main.tf
│ │ ├── remoteState.tf.off
│ │ ├── terraform.tfstate
│ │ └── variables.tf
│ └── networking
│ └── vpc
│ ├── main.tf
│ ├── terraform.tfstate
│ └── terraform.tfstate.backup
├── outputs.tf
└── remoteState.tf

My issue is though that there’s scenarios where I would like to run every single terraform to create an entire stack - in my situation it’s possible I will have up to 100+ VPCs all with identical infrastructure (one per customer).

At the moment I have to run each module individually. It’s certainly possible I’m just not grasping what Terraform is about.

Is there a way to run a global apply to create the entire stack and then in the future update individual components?

Sorry if this is confusing and I thank you for any help you may be able to give me.

Posts: 1

Participants: 1

Read full topic

How to Deploy lambda by terraform in diiferent aws envirenment

Destroy-time provisioner

$
0
0

@pgrinstead1 wrote:

Having some issues moving from .12.8 to lastest terraform.

My code:

resource "null_resource" "post_deploy_config" {
  depends_on = [module.nutanix_module]
  count      = var.resourcecount
  connection {
    type     = "ssh"
    host     = module.nutanix_module.vm_ip[count.index]
    user     = var.user
    password = var.pass
  }
  provisioner "remote-exec" {
    inline = [<<EOF
/bin/sudo /bin/systemctl restart gitlab-runner
EOF
    ]
  }
  provisioner "remote-exec" {
    when        = destroy
    on_failure  = continue
    inline = [<<EOF
sudo gitlab-runner unregister --all-runners
EOF
    ]
  }
}

But seeing the following error:
[LC02XG0YLJGH5]–[344530]–[~/Gitlab/terraform/gitlab-runner-ntnx-tf][:)]
$ terraform validate

Warning: External references from destroy provisioners are deprecated

on main.tf line 41, in resource “null_resource” “post_deploy_config”:
41: host = module.nutanix_module.vm_ips[count.index]

Destroy-time provisioners and their connection configurations may only
reference attributes of the related resource, via ‘self’, ‘count.index’, or
‘each.key’.

References to other resources during the destroy phase can cause dependency
cycles and interact poorly with create_before_destroy.

(and 2 more similar warnings elsewhere)

I am unclear how to get around this.

Posts: 1

Participants: 1

Read full topic

AWS RDS Cluster: database name was left blank. Terraform wants to destroy and create new

$
0
0

@gghatore wrote:

User created RDS using Console and left database name blank. Terraform is expecting this as mandatory and will destroy my instance. Any workaround other than recreate new cluster? Thanks

Posts: 1

Participants: 1

Read full topic

VPC Peering connection timeouts

$
0
0

@vmorkunas wrote:

Hello,

sometimes I get error while deleting VPC peering:

module.peering_ldap_data.aws_vpc_peering_connection.src_peering: apply errored, but we’re indicating that via the Error pointer rather than returning it: Error waiting for VPC Peering Connection (pcx-07e26e8d28e57dc9f) to be deleted: timeout while waiting for state to become ‘rejected, deleted’ (last state: ‘active’, timeout: 1m0s)

I know aws_vpc_peering_connection does not have timeout attribute so I cannot increase timeout for it. Maybe there is a workaround for it?

I tried to increase max_retries in backend-config while initing terraform, but it did not help.

Posts: 1

Participants: 1

Read full topic

Docker Deployment in App Engine | TerraForm

$
0
0

@harimuths wrote:

I have to deploy a docker container to the Google App Engine. In general we will do that in flex environment. I cant find any documentation related to App engine Flex environment.Is it possible to deploy a docker container to App engine using TerraForm. Please help me with it.

Posts: 1

Participants: 1

Read full topic

Name EC2 Instances with aws_launch_configuration

$
0
0

@jkprudhomme wrote:

I am currently using the aws_lauch_configuration to set up instances made with an aws_autoscaling_group. Is there a way to set up a schema for generating the names of these instances that get created? Currently they are all blank in the AWS Console

Posts: 1

Participants: 1

Read full topic


Vendoring providers in a module

$
0
0

@endrec wrote:

Hello,

I’d like to use a custom provider (which is not is the registry) with my infrastructure.
I can install that provider on my local machine, but that goes against creating reusable modules.

Is there a way to use custom providers without locally installing them previously (either by installing them with init or including them somewhere with the module source)?

Thanks,

Endre

Posts: 2

Participants: 1

Read full topic

Internal Server Error when applying on openstack

$
0
0

@ilveroluca wrote:

Hi,

I was trying to modify a somewhat old deployment on OpenStack. When I run terraform apply it’s failing to refresh the state of some items. I doesn’t give me a useful error but crashes with an “Internal Server Error”.

I’m using:

Terraform v0.11.11
+ provider.null v2.1.2
+ provider.openstack v1.26.0
+ provider.template v2.1.2

The original deployment was created with the same Terraform version but provider versions:

+ provider.null v2.1.0
+ provider.openstack v1.16.0
+ provider.template v2.1.0

I also tried applying with the original provider versions.

Running Terraform with TF_LOG=DEBUG and -parallelism=1 I get some more verbose output, like the following

openstack_compute_instance_v2.k8s_data_node_ext_net[2]: Refreshing state... (ID: a5204092-2d50-451b-9292-12238f26b748)
2020-03-05T16:17:51.135Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:17:51 [DEBUG] OpenStack Region is: jic
2020-03-05T16:17:51.135Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:17:51 [DEBUG] OpenStack Endpoint for compute: http://josc.jic.it:8774/v2.1/
2020-03-05T16:17:55.111Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:17:55 [DEBUG] Retrieved Server a5204092-2d50-451b-9292-12238f26b748: &{ID:a5204092-2d50-451b-9292-12238f26b748 TenantID:2f3ba940e96a4bb49b680dd4708f0c80 UserID:9463d48df8d54abca70e9b1954a6381c Name:tdm-stage-k8s-data-node-ext-net-3 Updated:2020-02-12 11:30:51 +0000 UTC Created:2019-07-10 13:28:38 +0000 UTC HostID:c6880f6db5e8e7b898231a6d044d111c67597f02b5b9b51095828f1d Status:ACTIVE Progress:0 AccessIPv4: AccessIPv6: Image:map[id:52a33989-1ed3-4240-846f-25e1532f3a8d links:[map[href:http://josc.jic.it:8774/images/52a33989-1ed3-4240-846f-25e1532f3a8d rel:bookmark]]] Flavor:map[id:ad25e075-11f0-412e-8514-d6b4c83b362f links:[map[href:http://josc.jic.it:8774/flavors/ad25e075-11f0-412e-8514-d6b4c83b362f rel:bookmark]]] Addresses:map[external_net:[map[OS-EXT-IPS-MAC:mac_addr:fa:16:3e:04:ed:61 OS-EXT-IPS:type:fixed addr:172.30.10.74 version:4]]] Metadata:map[depends_on:e9618922-1eef-4de8-9881-89777f573a37 kubespray_groups:kube-node,k8s-cluster,no-floating,k8s-data-node, ssh_user:ubuntu] Links:[map[href:http://josc.jic.it:8774/v2.1/servers/a5204092-2d50-451b-9292-12238f26b748 rel:self] map[href:http://josc.jic.it:8774/servers/a5204092-2d50-451b-9292-12238f26b748 rel:bookmark]] KeyName:kubernetes-tdm-stage AdminPass: SecurityGroups:[map[name:default] map[name:tdm-stage-k8s-worker] map[name:tdm-stage-k8s]] AttachedVolumes:[] Fault:{Code:0 Created:0001-01-01 00:00:00 +0000 UTC Details: Message:}}
2020-03-05T16:17:55.111Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:17:55 [DEBUG] OpenStack Region is: jic
2020-03-05T16:17:55.111Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:17:55 [DEBUG] OpenStack Endpoint for compute: http://josc.jic.it:8774/v2.1/
2020-03-05T16:18:01.053Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:18:01 [DEBUG] Addresses: map[string]interface {}{"external_net":[]interface {}{map[string]interface {}{"OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:04:ed:61", "OS-EXT-IPS:type":"fixed", "addr":"172.30.10.74", "version":4}}}
2020-03-05T16:18:01.053Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:18:01 [DEBUG] allInstanceAddresses: []openstack.InstanceAddresses{openstack.InstanceAddresses{NetworkName:"external_net", InstanceNICs:[]openstack.InstanceNIC{openstack.InstanceNIC{FixedIPv4:"172.30.10.74", FixedIPv6:"", MAC:"fa:16:3e:04:ed:61"}}}}
2020-03-05T16:18:01.053Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:18:01 [DEBUG] getAllInstanceNetworks: []openstack.InstanceNetwork{openstack.InstanceNetwork{UUID:"2f0db58d-fd9f-4cd8-83fb-59c225a06dc0", Name:"external_net", Port:"", FixedIP:"172.30.10.74", AccessNetwork:false}}
2020-03-05T16:18:01.054Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:18:01 [DEBUG] flattenInstanceNetworks: []map[string]interface {}{map[string]interface {}{"access_network":false, "fixed_ip_v4":"172.30.10.74", "fixed_ip_v6":"", "mac":"fa:16:3e:04:ed:61", "name":"external_net", "port":"", "uuid":"2f0db58d-fd9f-4cd8-83fb-59c225a06dc0"}}
2020-03-05T16:18:01.054Z [DEBUG] plugin.terraform-provider-openstack_v1.26.0_x4: 2020/03/05 16:18:01 [DEBUG] OpenStack Instance Network Access Addresses: 172.30.10.74,
2020/03/05 16:18:12 [ERROR] root.compute: eval: *terraform.EvalRefresh, err: openstack_compute_instance_v2.k8s_data_node_ext_net.2: Internal Server Error
2020/03/05 16:18:12 [ERROR] root.compute: eval: *terraform.EvalSequence, err: openstack_compute_instance_v2.k8s_data_node_ext_net.2: Internal Server Error
2020/03/05 16:18:12 [TRACE] [walkRefresh] Exiting eval tree: module.compute.openstack_compute_instance_v2.k8s_data_node_ext_net[2]
2020/03/05 16:18:12 [TRACE] root.compute: eval: *terraform.EvalSequence

Does anyone have an idea of what may be going on here? I can provide more log output should it be helpful.

Cheers,

Luca

Posts: 1

Participants: 1

Read full topic

Licensing terms

$
0
0

@ksbharadwaj wrote:

Hi,
What are the licensing terms for distributing the terraform scripts that we write to our customers? What needs to be included along with the scripts? Can the terraform binary be distributed?

Posts: 2

Participants: 2

Read full topic

Working with List and Variables

$
0
0

@allenstecat wrote:

Attempting to create a list of groups in AAD when my code runs everything is fine accept the code only creates the first group name in the list and never creates the others. My code:
variable “azuread_group_name” {
description = “This is the variable file for user input for creating AAD Groups…”
type = list
default = [“c12test”, “c12tester1”, “c12tester3”]
}

Posts: 1

Participants: 1

Read full topic

Create AzureServiceBus topics, subscrioptions and rules

$
0
0

@kreuzj wrote:

Hello,
I’m newbie in TF templates, just trying to resolve following scenario: need to create multiple AzureServiceBus topics with subscriptions (one to any). Each subscription can contain one to N rules. I just want to manage topics, subscriptions and rules on one place. My idea was to have config file holding required objects configuration and looking somehow as following sample (names used in the example are just placeholders, the topics sesction would finally definitelly have more than one topic)

"topics": [
    {
        "topicName": "test-topic1",
        "subscriptions":[
            {
                "subsriptionName":"to-test",
                "rules":[
                    {
                        "rule":{
                            "ruleFilterExpression" : "TARGET='TEST'",
                            "ruleActionExpression" :"",
                            "ruleSuffix":"-for-TEST"
                        }
                    }
                ],
                "subscriptionSettings":{
                    "status": "Disabled"
                }
            },
            {
                "subsriptionName":"from-test",
                "rules":[
                    {
                        "rule":{
                            "ruleFilterExpression" : "SOURCE='TEST'",
                            "ruleActionExpression" :"",
                            "ruleSuffix":"-to-TEST"
                        }
                    }
                ],
                "subscriptionSettings":{
                    "status": "Disabled"
                }
            }
        ]
        
    }
]

}

I already tried to create such deployment using ARM template but failed as wasn’t able to create nested loops there… I found that TF supports nested loops bud didn’t find any example similar to above described so the question is if I would be able to accomodate my above usecase using TF template. Can somebody pls. help?

Thanks
Jan Kreuz

Posts: 2

Participants: 2

Read full topic

Error: could not find resource pool ID ""

$
0
0

@Tekcraft wrote:

Using the VSphere Provider I’m trying to use Terraform to create multiple VM.

I’m using a variable “deploy”:

variable "deploy" {
  type    = list
  default = []
}

and created a list of values for the resource

resource "vsphere_virtual_machine" "deploy" {
  count = length(var.deploy)
  name  = var.deploy[count.index]["hostname"]

  resource_pool_id     = var.deploy[count.index]["resource_pool"]
  num_cpus             = var.deploy[count.index]["CPU_Count"]
  num_cores_per_socket = var.deploy[count.index]["cores"]
  memory               = var.deploy[count.index]["RAM"]
  annotation           = var.deploy[count.index]["Tag"]
  folder               = var.deploy[count.index]["folder_path"]

with the following tfvars:

deploy  = [
    {
        hostname       = "test"
#        template       = "ubuntu-server-18.04.3-LTS"
        AssetTag       = "1234322"  # This will create an entry in the advanced settings of the VM
        CPU_Count      = "1"
        cores          = "2"
        RAM            = "4000"
        Tag            = "Test"  
        disk0          = "30"
        folder_path    = "<path>"
        resource_pool  = "<resource_pool>"
        vlan           = "<vlan_id>"
        domain         = "<domain>"
        ip             = "10.64.x.x"
        netmask        = "23"
        gateway        = "10.64.x.1"
        dns1           = "10.x.x.11"
        dns2           = "10.x.x.12"
    }
]

but when I execute terraform plan I have the following error:

Error: could not find resource pool ID "<resource_pool>": ServerFaultCode: The object 'vim.ResourcePool:<resource_pool>' has already been deleted or has not been completely created

  on main.tf line 39, in resource "vsphere_virtual_machine" "deploy":
  39: resource "vsphere_virtual_machine" "deploy" {

If I use a general variable assignment in terraform.tfvars (and not in the deploy section) and I change the entry from:
resource_pool_id = var.deploy[count.index][“resource_pool”]
to
resource_pool_id = data.vsphere_resource_pool.pool.id

I have no error.

Any idea why?

Posts: 2

Participants: 2

Read full topic

Access a value in tfstate with a property that contains a space

$
0
0

@dprosper wrote:

I wish to access a value in the Terraform state that contains a space in it, i.e.
“type”: “my_resource”
“name”: “my_name”,
“instances” [
{
“attributes” {
“Access Key”: “1231-3131-2134”
}
}
]

I wish to use the “Access Key” inside of my template, but I can’t find a way that will accept the space in the property, I tried with enclosing it in [ ], “” and [ " " ], but none of those work. I get an error each time: Error: Invalid attribute name

Posts: 2

Participants: 1

Read full topic


For_each with list(number)

$
0
0

@h3adache wrote:

On the document for for_each it says

The for_each meta-argument accepts a map or a set of strings, and creates an instance for each item in that map or set. Each instance has a distinct infrastructure object associated with it (as described above in Resource Behavior), and each is separately created, updated, or destroyed when the configuration is applied.

Is there a way to convert a list(number) to list(string).
Even if I declare a variable. as type list(string) and pass in a list of numbers (ports for example), it seems that it still knows that it’s a list of numbers and fails.

Posts: 3

Participants: 2

Read full topic

Having issues with passing array to a local_exec provisioner

$
0
0

@rmattier wrote:

I am currently running a ansible-playbook via a local-exec within an aws_instance resource. The terraform apply results in an error" “Error: Cycle: aws_instance.server[2], aws_instance.server[1], aws_instance.server[0]” I’m trying to figure out the best way to get passing the array via the extra-vars. The provisioner line looks like:

provisioner “local-exec” {
command = “ansible-playbook -e ‘hostname=server-master-{count.index + 1} node_type=master environ={var.environ} elastic_masters={ aws_instance.server.*.private_dns)}' -u ec2-user -i '{self.private_ip},’ --private-key ‘~/.ssh/id_rsa’ provis.yml”
}

Posts: 2

Participants: 2

Read full topic

Importing Okta OIN Org2Org Application

$
0
0

@mzaidi1 wrote:

Hello Community,
I’m new to Terraform, but I’m trying to understand how to manage an OIN asset that currently exists in Okta, that I can import, and then integrate as a part of my apps.tf file. So I’ve performed the import process where a new terraform.tfstate file is created, but I would like to now see all the details in the to be filled out in my json object that was originally used to pull down my OIN app to be populated. I hope I’m not getting the concept incorrectly but I would appreciate any help in understanding to be able to pull an OIN app down and manage it.

thank you,

Posts: 3

Participants: 2

Read full topic

Terraform in diiferent aws envirenment

Calculate azure availability zone from count.index

$
0
0

@getvivekv wrote:

azurerm_linux_virtual_machine contains a “zone” key, where we can input a zone number such as 1, 2 or 3 for an azure vm. This works fine for a single VM. However, if I want to deploy n number of virtual machine and I add “count” variable in the resource, then how can I automatically calculate the zone key so that each VM is deployed on different zone.

Eg, I want to stand up 5 VMs
vm1- zone -1
vm2- zone -2
vm3- zone -3
vm4- zone -1
vm]5- zone -2

Posts: 1

Participants: 1

Read full topic

Viewing all 11395 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>