Skip to content

Instantly share code, notes, and snippets.

@lambdafunc
Last active July 5, 2021 14:25
Show Gist options
  • Select an option

  • Save lambdafunc/72b5c80485f649ee6037bd9e515e7946 to your computer and use it in GitHub Desktop.

Select an option

Save lambdafunc/72b5c80485f649ee6037bd9e515e7946 to your computer and use it in GitHub Desktop.
variables basics in tf
provider "aws" {
region = "us-east-1"
# Not a recommended way, either pass this in as ENV variables
# or configure using aws cli or attach policy to EC2 instance
access_key = "access_key"
secret_key = "secret_key"
}
variable "subnet_cidr_block" {
description = "subnet cidr block"
# Default value if needed
default = "10.0.10.0/24"
# What type of values will be accepted if you want to specify
# type = string
}
resource "aws_vpc" "dev-vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "dev-subnet" {
vpc_id = aws_vpc.dev-vpc.id
cidr_block = var.subnet_cidr_block
availability_zone = "us-east-1a"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment