Difference between revisions of "Terraform: subnet id"

From wikieduonline
Jump to navigation Jump to search
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
* <code>[[subnet_id]]</code>
+
Terraform <code>[[subnet_id]]</code> [[argument]] used in:
 +
* [[Terraform resource: aws_instance]]
 +
* [[Terraform module: ec2-instance]]
  
  
 +
* <code>[[aws ec2 describe-subnets]] --output json | grep SubnetId</code>
 
* <code>[[aws ec2 describe-instances]]  | grep -i [[SubnetId]]</code>
 
* <code>[[aws ec2 describe-instances]]  | grep -i [[SubnetId]]</code>
  
 +
== Examples ==
 +
* <code>subnet_id = "subnet-0a72be05b421abcde"</code>
 +
* <code>subnet_id = [[element]]([[data.aws_subnets]].all_private.ids, 0)</code>
  
 +
== Errors ==
 
* <code>[[terraform plan]]</code>
 
* <code>[[terraform plan]]</code>
 
  │ Error: Error in function call
 
  │ Error: Error in function call
 
  │
 
  │
 
  │  on ../path_to_your/plan.tf line 7, in resource "[[aws_instance]]" "this":
 
  │  on ../path_to_your/plan.tf line 7, in resource "[[aws_instance]]" "this":
  │    7:  subnet_id = element(var.subnet_ids,count.index)
+
  │    7:  subnet_id = element([[var.subnet_ids]],[[count.index]])
 
  │    ├────────────────
 
  │    ├────────────────
 
  │    │ count.index is 0
 
  │    │ count.index is 0
Line 16: Line 23:
 
  │ Call to function "[[element]]" failed: cannot use element function with an empty list.
 
  │ Call to function "[[element]]" failed: cannot use element function with an empty list.
  
 +
* <code>[[InvalidSubnetID]]</code>
 +
 +
== Related  ==
 +
* <code>[[aws_subnet_ids]]</code>
 +
* [[aws_subnet]]
 +
* [[Terraform: VPCIdNotSpecified]]
 +
tf show | grep subnet_id
 +
tf show | egrep "subnet_id|connectivity_type"
 +
* [[Terraform module: ec2-instance]]
  
 
== See also ==
 
== See also ==
 
* {{aws_instance}}
 
* {{aws_instance}}
* {{Terraform}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 11:59, 20 October 2023

Terraform subnet_id argument used in:


Examples[edit]

Errors[edit]

│ Error: Error in function call
│
│   on ../path_to_your/plan.tf line 7, in resource "aws_instance" "this":
│    7:   subnet_id = element(var.subnet_ids,count.index)
│     ├────────────────
│     │ count.index is 0
│     │ var.subnet_ids is empty list of string
│
│ Call to function "element" failed: cannot use element function with an empty list.

Related[edit]

tf show | grep subnet_id
tf show | egrep "subnet_id|connectivity_type"

See also[edit]

Advertising: