mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-22 20:01:58 +01:00
Add example.tf with DO resource
This commit is contained in:
parent
a0be69b77b
commit
ce6f474f0f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/terraform-inventory
|
||||
/fixtures/secrets.tfvars
|
||||
|
@ -41,6 +41,9 @@ It's just a Go app, so the usual:
|
||||
cd $GOPATH/adammck/terraform-inventory
|
||||
go build
|
||||
|
||||
To update the fixtures, populate `fixtures/secrets.tfvars` with your DO and AWS
|
||||
account details, and run `fixtures/update`. You probably don't need to do this.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
|
31
fixtures/example.tf
Normal file
31
fixtures/example.tf
Normal file
@ -0,0 +1,31 @@
|
||||
variable "do_token" {}
|
||||
variable "aws_access_key" {}
|
||||
variable "aws_secret_key" {}
|
||||
variable "aws_subnet_id" {}
|
||||
|
||||
provider "aws" {
|
||||
access_key = "${var.aws_access_key}"
|
||||
secret_key = "${var.aws_secret_key}"
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
provider "digitalocean" {
|
||||
token = "${var.do_token}"
|
||||
}
|
||||
|
||||
resource "aws_instance" "web-aws" {
|
||||
ami = "ami-96a818fe"
|
||||
instance_type = "t2.micro"
|
||||
subnet_id = "${var.aws_subnet_id}"
|
||||
root_block_device = {
|
||||
delete_on_termination = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet" "web-do" {
|
||||
image = "centos-7-0-x64"
|
||||
name = "terraform-inventory-1"
|
||||
region = "nyc1"
|
||||
size = "512mb"
|
||||
ssh_keys = [55015]
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"serial": 1,
|
||||
"serial": 11,
|
||||
"modules": [
|
||||
{
|
||||
"path": [
|
||||
@ -8,103 +8,53 @@
|
||||
],
|
||||
"outputs": {},
|
||||
"resources": {
|
||||
"aws_instance.one": {
|
||||
"aws_instance.web-aws": {
|
||||
"type": "aws_instance",
|
||||
"depends_on": [
|
||||
"aws_security_group.example"
|
||||
],
|
||||
"primary": {
|
||||
"id": "i-aaaaaaaa",
|
||||
"id": "i-366736e6",
|
||||
"attributes": {
|
||||
"ami": "ami-XXXXXXXX",
|
||||
"availability_zone": "us-east-1b",
|
||||
"id": "i-aaaaaaaa",
|
||||
"ami": "ami-96a818fe",
|
||||
"availability_zone": "us-east-1d",
|
||||
"ebs_block_device.#": "0",
|
||||
"ebs_optimized": "false",
|
||||
"ephemeral_block_device.#": "0",
|
||||
"id": "i-366736e6",
|
||||
"instance_type": "t2.micro",
|
||||
"key_name": "",
|
||||
"private_dns": "ip-1-1-1-1.ec2.internal",
|
||||
"private_ip": "1.1.1.1",
|
||||
"private_dns": "ip-10-0-0-4.ec2.internal",
|
||||
"private_ip": "10.0.0.4",
|
||||
"public_dns": "",
|
||||
"public_ip": "",
|
||||
"security_groups.#": "1",
|
||||
"security_groups.0": "sg-cccccccc",
|
||||
"subnet_id": "subnet-XXXXXXXX",
|
||||
"tenancy": "default"
|
||||
"root_block_device.#": "1",
|
||||
"root_block_device.0.delete_on_termination": "true",
|
||||
"root_block_device.0.iops": "0",
|
||||
"root_block_device.0.volume_size": "8",
|
||||
"root_block_device.0.volume_type": "standard",
|
||||
"security_groups.#": "0",
|
||||
"subnet_id": "subnet-59f9b32e",
|
||||
"tags.#": "0",
|
||||
"tenancy": "default",
|
||||
"vpc_security_group_ids.#": "1",
|
||||
"vpc_security_group_ids.2076429742": "sg-b42329d0"
|
||||
},
|
||||
"meta": {
|
||||
"schema_version": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"aws_instance.two": {
|
||||
"type": "aws_instance",
|
||||
"depends_on": [
|
||||
"aws_security_group.example"
|
||||
],
|
||||
"digitalocean_droplet.web-do": {
|
||||
"type": "digitalocean_droplet",
|
||||
"primary": {
|
||||
"id": "i-bbbbbbbb",
|
||||
"id": "5579362",
|
||||
"attributes": {
|
||||
"ami": "ami-XXXXXXXX",
|
||||
"availability_zone": "us-east-1b",
|
||||
"id": "i-bbbbbbbb",
|
||||
"instance_type": "t2.micro",
|
||||
"key_name": "",
|
||||
"private_dns": "ip-2-2-2-2.ec2.internal",
|
||||
"private_ip": "2.2.2.2",
|
||||
"public_dns": "",
|
||||
"public_ip": "",
|
||||
"security_groups.#": "1",
|
||||
"security_groups.0": "sg-cccccccc",
|
||||
"subnet_id": "subnet-XXXXXXXX",
|
||||
"tenancy": "default"
|
||||
}
|
||||
}
|
||||
},
|
||||
"aws_route53_record.example": {
|
||||
"type": "aws_route53_record",
|
||||
"depends_on": [
|
||||
"aws_instance.one",
|
||||
"aws_instance.two"
|
||||
],
|
||||
"primary": {
|
||||
"id": "XXXXXXXXXXXXXX_something.example.com_CNAME",
|
||||
"attributes": {
|
||||
"id": "XXXXXXXXXXXXXX_something.example.com_CNAME",
|
||||
"name": "something.example.com",
|
||||
"records.#": "2",
|
||||
"records.0": "i-aaaaaaaa",
|
||||
"records.1": "i-bbbbbbbb",
|
||||
"ttl": "300",
|
||||
"type": "CNAME",
|
||||
"zone_id": "XXXXXXXXXXXXXX"
|
||||
}
|
||||
}
|
||||
},
|
||||
"aws_security_group.example": {
|
||||
"type": "aws_security_group",
|
||||
"primary": {
|
||||
"id": "sg-cccccccc",
|
||||
"attributes": {
|
||||
"description": "Allow SSH and HTTP from inside the firewall",
|
||||
"id": "sg-cccccccc",
|
||||
"ingress.#": "2",
|
||||
"ingress.0.cidr_blocks.#": "2",
|
||||
"ingress.0.cidr_blocks.0": "10.0.0.0/8",
|
||||
"ingress.0.cidr_blocks.1": "192.168.0.0/16",
|
||||
"ingress.0.from_port": "22",
|
||||
"ingress.0.protocol": "tcp",
|
||||
"ingress.0.security_groups.#": "0",
|
||||
"ingress.0.self": "false",
|
||||
"ingress.0.to_port": "22",
|
||||
"ingress.1.cidr_blocks.#": "2",
|
||||
"ingress.1.cidr_blocks.0": "10.0.0.0/8",
|
||||
"ingress.1.cidr_blocks.1": "192.168.0.0/16",
|
||||
"ingress.1.from_port": "80",
|
||||
"ingress.1.protocol": "tcp",
|
||||
"ingress.1.security_groups.#": "0",
|
||||
"ingress.1.self": "false",
|
||||
"ingress.1.to_port": "80",
|
||||
"name": "example",
|
||||
"owner_id": "111111111111",
|
||||
"tags.App": "my_app",
|
||||
"tags.Environment": "my_env",
|
||||
"vpc_id": "vpc-XXXXXXXX"
|
||||
"id": "5579362",
|
||||
"image": "centos-7-0-x64",
|
||||
"ipv4_address": "192.241.136.44",
|
||||
"locked": "false",
|
||||
"name": "terraform-inventory-1",
|
||||
"region": "nyc1",
|
||||
"size": "512mb",
|
||||
"ssh_keys.#": "1",
|
||||
"ssh_keys.0": "55015",
|
||||
"status": "active"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
fixtures/secrets.tfvars.example
Normal file
4
fixtures/secrets.tfvars.example
Normal file
@ -0,0 +1,4 @@
|
||||
do_token = ""
|
||||
aws_access_key = ""
|
||||
aws_secret_key = ""
|
||||
aws_subnet_id = ""
|
3
fixtures/update
Executable file
3
fixtures/update
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash -e
|
||||
cd $(cd `dirname "$0"`; cd ..; pwd)
|
||||
terraform apply -refresh -var-file="fixtures/secrets.tfvars" -state="fixtures/example.tfstate" -backup="-" fixtures
|
Loading…
Reference in New Issue
Block a user