From b71b6958d82f16d61eced174d18c169e3f62dc36 Mon Sep 17 00:00:00 2001 From: Jordan Caussat Date: Tue, 10 Apr 2018 12:22:07 +0200 Subject: [PATCH] TER-263: Update basic example using all parameters and more examples (2 features examples) --- examples/basic/main.tf | 123 ++++++++++++++--------- examples/shared_modules_features/main.tf | 67 ++++-------- 2 files changed, 96 insertions(+), 94 deletions(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 0ae36b6..d01aa9f 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -11,87 +11,118 @@ resource "ghost_app" "test" { region = "eu-west-1" instance_type = "t2.micro" - vpc_id = "vpc-3f1eb65a" + vpc_id = "vpc-1234567" log_notifications = [ "ghost-devops@domain.com", ] build_infos = { - subnet_id = "subnet-a7e849fe" + subnet_id = "subnet-1234567" ssh_username = "admin" - source_ami = "ami-03ce4474" + source_ami = "ami-1234567" } environment_infos = { - instance_profile = "iam.ec2.demo" - key_name = "ghost-demo" + 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 - }] + optional_volumes = [ + { + device_name = "/dev/xvdd" + volume_type = "gp2" + volume_size = 20 + iops = 0 + }, + ] - subnet_ids = ["subnet-a7e849fe"] - security_groups = ["sg-6814f60c", "sg-2414f60c"] + subnet_ids = ["subnet-1234567"] + security_groups = ["sg-1234567", "sg-1234567"] - instance_tags = [{ - tag_name = "Name" - tag_value = "wordpress" - }, + instance_tags = [ { - tag_name = "Type" - tag_value = "front" + tag_name = "Name" + tag_value = "wordpress" }, ] } autoscale = { - name = "autoscale" - min = 1 - max = 3 + name = "autoscale" + min = 1 + max = 3 + enable_metrics = true } - modules = [{ - name = "wordpress" - pre_deploy = "" - path = "/var/www" - scope = "code" - git_repo = "https://github.com/KnpLabs/KnpIpsum.git" - }, + modules = [ { - name = "wordpress2" - pre_deploy = "ZXhpdCAx" - post_deploy = "ZXhpdCAx" - path = "/var/www" - scope = "code" - git_repo = "https://github.com/KnpLabs/KnpIpsum.git" + 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 = [{ - version = "5.4" - name = "php5" - }, + features = [ { - version = "2.2" - name = "apache2" + name = "php5" + version = "5.4" + provisioner = "salt" + }, + { + name = "package" + provisioner = "ansible" + + parameters = <<-JSON + { + "package_name" : [ + "nano", + "cowsay", + "ffmpeg", + "curl" + ] + } + JSON }, ] lifecycle_hooks = { - pre_buildimage = "#!/usr/bin/env bash" - post_buildimage = "#!/usr/bin/env bash" + 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" - }] + environment_variables = [ + { + key = "myvar" + value = "myvalue" + }, + ] + + safe_deployment = { + load_balancer_type = "elb" + wait_before_deploy = 10 + wait_after_deploy = 10 + api_port = 5001 + app_tag_value = "" + ha_backend = "" + } } diff --git a/examples/shared_modules_features/main.tf b/examples/shared_modules_features/main.tf index 48b1fd0..b6d75b4 100644 --- a/examples/shared_modules_features/main.tf +++ b/examples/shared_modules_features/main.tf @@ -11,63 +11,22 @@ resource "ghost_app" "test" { region = "eu-west-1" instance_type = "t2.micro" - vpc_id = "vpc-3f1eb65a" - - log_notifications = [ - "ghost-devops@domain.com", - ] + vpc_id = "vpc-1234567" build_infos = { - subnet_id = "subnet-a7e849fe" + subnet_id = "subnet-1234567" ssh_username = "admin" - source_ami = "ami-03ce4474" + source_ami = "ami-1234567" } environment_infos = { instance_profile = "iam.ec2.demo" key_name = "ghost-demo" - root_block_device = { - name = "testblockdevice" - size = 20 - } - - optional_volumes = [{ - device_name = "/dev/xvdd" - volume_type = "gp2" - volume_size = 20 - }] - - subnet_ids = ["subnet-a7e849fe"] - security_groups = ["sg-6814f60c", "sg-2414f60c"] - - instance_tags = [{ - tag_name = "Name" - tag_value = "wordpress" - }, - { - tag_name = "Type" - tag_value = "front" - }, - ] + subnet_ids = ["subnet-1234567"] + security_groups = ["sg-1234567"] } - autoscale = { - name = "autoscale" - min = 1 - max = 3 - } - - lifecycle_hooks = { - pre_buildimage = "#!/usr/bin/env bash" - post_buildimage = "#!/usr/bin/env bash" - } - - environment_variables = [{ - key = "myvar" - value = "myvalue" - }] - // Several modules and/or lists of modules can be merged together. modules = "${concat(list(local.custom_module_1, local.custom_module_2), local.basic_modules)}" @@ -119,7 +78,19 @@ locals { locals { custom_feature = { - name = "feature_1" - version = "1" + name = "feature_1" + version = "1" + provisioner = "ansible" + + parameters = <<-JSON + { + "package_name" : [ + "nano", + "cowsay", + "ffmpeg", + "curl" + ] + } + JSON } }