Last active
November 10, 2015 18:53
-
-
Save clstokes/217a177a9c6881f17cea to your computer and use it in GitHub Desktop.
📝 Working HashiCorp Atlas and DigitalOcean example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"region": "nyc2", | |
"source_image": "ubuntu-14-04-x64", | |
"atlas_username": "{{ env `ATLAS_USERNAME` }}", | |
"atlas_name": "digitalocean-example" | |
}, | |
"builders": [{ | |
"type": "digitalocean", | |
"image": "{{user `source_image`}}", | |
"region": "{{user `region`}}", | |
"size": "512mb" | |
}], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": [ | |
"sudo apt-get update -y", | |
"sudo apt-get install -y apache2" | |
] | |
} | |
], | |
"push": { | |
"name": "{{user `atlas_username`}}/{{user `atlas_name`}}", | |
"vcs": false | |
}, | |
"post-processors": [ | |
[ | |
{ | |
"type": "atlas", | |
"artifact": "{{user `atlas_username`}}/{{user `atlas_name`}}", | |
"artifact_type": "digitalocean.image", | |
"metadata": { | |
"created_at": "{{timestamp}}" | |
} | |
} | |
] | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "digitalocean" { | |
} | |
resource "atlas_artifact" "example" { | |
name = "clstokes/digitalocean-example" | |
type = "digitalocean.image" | |
} | |
resource "digitalocean_droplet" "example" { | |
image = "${atlas_artifact.example.id}" | |
name = "example" | |
region = "nyc2" | |
size = "512mb" | |
ssh_keys = ["${digitalocean_ssh_key.example.id}"] | |
} | |
resource "digitalocean_ssh_key" "example" { | |
name = "atlas-example" | |
public_key = "${file("~/.ssh/id_rsa.pub")}" | |
} | |
output "droplet_info" { | |
value = "ssh root@${digitalocean_droplet.example.ipv4_address}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ terraform apply terraform | |
digitalocean_ssh_key.example: Creating... | |
fingerprint: "" => "<computed>" | |
name: "" => "atlas-example" | |
public_key: "" => "SNIP" | |
atlas_artifact.example: Creating... | |
file_url: "" => "<computed>" | |
metadata_full.#: "" => "<computed>" | |
name: "" => "clstokes/digitalocean-example" | |
slug: "" => "<computed>" | |
type: "" => "digitalocean.image" | |
version_real: "" => "<computed>" | |
atlas_artifact.example: Creation complete | |
digitalocean_ssh_key.example: Creation complete | |
digitalocean_droplet.example: Creating... | |
image: "" => "14145215" | |
ipv4_address: "" => "<computed>" | |
ipv4_address_private: "" => "<computed>" | |
ipv6_address: "" => "<computed>" | |
ipv6_address_private: "" => "<computed>" | |
locked: "" => "<computed>" | |
name: "" => "example" | |
region: "" => "nyc2" | |
size: "" => "512mb" | |
ssh_keys.#: "" => "1" | |
ssh_keys.0: "" => "1536145" | |
status: "" => "<computed>" | |
digitalocean_droplet.example: Creation complete | |
Apply complete! Resources: 3 added, 0 changed, 0 destroyed. | |
The state of your infrastructure has been saved to the path | |
below. This state is required to modify and destroy your | |
infrastructure, so keep it safe. To inspect the complete state | |
use the `terraform show` command. | |
State path: terraform.tfstate | |
Outputs: | |
droplet_info = ssh [email protected] | |
$ terraform destroy terraform | |
Do you really want to destroy? | |
Terraform will delete all your managed infrastructure. | |
There is no undo. Only 'yes' will be accepted to confirm. | |
Enter a value: yes | |
digitalocean_ssh_key.example: Refreshing state... (ID: 1536145) | |
atlas_artifact.example: Refreshing state... (ID: 14145215) | |
digitalocean_droplet.example: Refreshing state... (ID: 8457607) | |
digitalocean_droplet.example: Destroying... | |
digitalocean_droplet.example: Destruction complete | |
digitalocean_ssh_key.example: Destroying... | |
atlas_artifact.example: Destroying... | |
atlas_artifact.example: Destruction complete | |
digitalocean_ssh_key.example: Destruction complete | |
Apply complete! Resources: 0 added, 0 changed, 3 destroyed. | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment