Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
TER-263: Add import example and update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat committed Apr 10, 2018
1 parent b71b695 commit 76d65ee
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 2 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ Examples are available in the examples directory:
- `basic`: shows how to define a simple ghost application
- `shared_modules_features`: shows how modules and features can be shared across ghost\_app resources using `locals`. It also shows how to write or import scripts.

Create a new Ghost App
---------------------------
First make sure the provider is installed as described above.

Create your app configuration using the examples available.

Run
```sh
$ terraform init # or tfwrapper init
$ terraform apply # or tfwrapper apply
```

Import an existing Ghost App
---------------------------
First make sure the provider is installed as described above.

Create your app configuration using the import examples available.

Run terraform import ghost_app.your_app app_id. Example:
```sh
$ terraform import ghost_app.basic_import 5accabf63d7eba00014e5679 # or tfwrapper import
```

Developing the Provider
---------------------------

Expand Down
2 changes: 1 addition & 1 deletion examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "ghost" {
endpoint = "https://localhost"
}

resource "ghost_app" "test" {
resource "ghost_app" "basic" {
name = "wordpress"
env = "dev"
role = "webfront"
Expand Down
1 change: 1 addition & 0 deletions examples/basic_import/inputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable "password" {}
120 changes: 120 additions & 0 deletions examples/basic_import/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
provider "ghost" {
user = "demo"
password = "${var.password}"
endpoint = "https://localhost"
}

resource "ghost_app" "basic_import" {
// You can ignore parameters using lifecycle.ignore_changes meta-parameter
lifecycle {
ignore_changes = ["log_notifications", "safe_deployment"]
}

name = "wordpress"
env = "dev"
role = "webfront"

region = "eu-west-1"
instance_type = "t2.micro"
vpc_id = "vpc-1234567"

build_infos = {
subnet_id = "subnet-1234567"
ssh_username = "admin"
source_ami = "ami-1234567"
}

environment_infos = {
instance_profile = "iam.ec2.demo"
key_name = "ghost-demo"
public_ip_address = true

root_block_device = {
name = "testblockdevice"
size = 20
}

optional_volumes = [
{
device_name = "/dev/xvdd"
volume_type = "gp2"
volume_size = 20
iops = 0
},
]

subnet_ids = ["subnet-1234567"]
security_groups = ["sg-1234567", "sg-1234567"]

instance_tags = [
{
tag_name = "Name"
tag_value = "wordpress"
},
]
}

autoscale = {
name = "autoscale"
min = 1
max = 3
enable_metrics = true
}

modules = [
{
name = "wordpress"
path = "/var/www"
scope = "code"
git_repo = "https://github.com/KnpLabs/KnpIpsum.git"
uid = 0
gid = 0
build_pack = ""
pre_deploy = ""
post_deploy = ""
after_all_deploy = ""
},
]

features = [
{
name = "php5"
version = "5.4"
provisioner = "salt"
},
{
name = "package"
provisioner = "ansible"

parameters = <<-JSON
{
"package_name" : [
"nano",
"cowsay",
"ffmpeg",
"curl"
]
}
JSON
},
]

lifecycle_hooks = {
pre_buildimage = "echo PRE_BUILD >> /var/www/html/wp-config.php"

post_buildimage = <<-SCRIPT
#!/bin/bash
echo "EXAMPLE_CONFIG" >> /var/www/html/wp-config.php
SCRIPT

pre_bootstrap = ""
post_bootstrap = ""
}

environment_variables = [
{
key = "myvar"
value = "myvalue"
},
]
}
9 changes: 8 additions & 1 deletion examples/shared_modules_features/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "ghost" {
endpoint = "https://localhost"
}

resource "ghost_app" "test" {
resource "ghost_app" "shared_modules_features" {
name = "wordpress"
env = "dev"
role = "webfront"
Expand All @@ -25,6 +25,13 @@ resource "ghost_app" "test" {

subnet_ids = ["subnet-1234567"]
security_groups = ["sg-1234567"]

instance_tags = [
{
tag_name = "Name"
tag_value = "wordpress"
},
]
}

// Several modules and/or lists of modules can be merged together.
Expand Down

0 comments on commit 76d65ee

Please sign in to comment.