/************************************************
* Instance resource for module
***********************************************/
resource "cloudstack_instance" "ci_simple" {
name = "${format("tf-%v-%v-%v-%v", var.instance_name, var.service, var.client, var.env)}"
service_offering = "${var.service_offering}"
template = "${var.instance_template}"
network_id = "${var.network_id}"
ip_address = "${var.ip_address}"
zone = "${var.cs_zone}"
root_disk_size = "${var.root_disk_size}"
user_data = "${data.template_cloudinit_config.config.rendered}"
keypair = "${var.ssh_keypair}"
expunge = true
}
module "rundeck" {
source = "../../tf-axidpp-infra-mods/ci_simple"
cs_zone = "${var.cs_zone}"
network_id = "${module.vpc.subnet_app_id}"
ssh_keypair = "${cloudstack_ssh_keypair.bastion-axidpp-prod.name}"
instance_name = "rundeck"
instance_template = "${var.instance_template}"
root_disk_size = "50"
service = "${var.service}"
client = "${var.client}"
env = "${var.env}"
prov-reg = "${var.prov-reg}"
domain = "${var.domain}"
salt_master_fqdn = "${var.salt_master_fqdn}"
salt_minion_version = "${var.salt_minion_version}"
user-data = "userdata_pk.tpl"
host_ssh_private = "${cloudstack_ssh_keypair.rundeck-axidpp-prod.private_key}"
}
Terraform will perform the following actions:
+ module.bwide-etl.cloudstack_instance.ci_simple
id: <computed>
display_name: <computed>
expunge: "true"
group: <computed>
ip_address: "10.109.40.12"
keypair: "bastion-axidpp-prod"
name: "tf-bwide-etl-dpp-axi-prod"
network_id: "f61214b6-7477-46ac-b3c2-e1548de3f242"
project: <computed>
root_disk_size: "20"
service_offering: "4vCPU-8GB-SSD-STD-SF"
tags.%: <computed>
template: "AXI-CentOS-7-x86_64-Minimal"
user_data: "fc53581e3bca48406e504baba280a56c4d6dd0d0"
zone: "swiss1"
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
2018/04/26 11:14:21 [INFO] terraform: building graph: GraphTypeApply
ervice'\n - 'systemctl restart salt-minion.service'\nwrite_files:\n - content: |\n alias ls='ls --color=auto'\n alias grep='grep --color=auto'\n N=\"\\[\\e[0m\\]\"\n R=\"\\[\\e[1;31m\\]\"\n G=\"\\[\\033[32m\\]\"\n if [[ $EUID == 0 ]] ; then\n PS1=\"$R\\u@\\h :[ $N\\w$R ]:# $N\"\n else\n PS1=\"$G\\u@\\h :[ $N\\w$G ]:\\$ $N\"\n fi\n unset R G N\n#\n path: /etc/skel/.bashrc\n owner: root:root\n permissions: '0644'\r\n--MIMEBOUNDARY--\r\n", RequiresNew:false, Sensitive:false, Type:0x0}, "root_disk_size":*terraform.ResourceAttrDiff{Old:"", New:"20", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "project":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "network_id":*terraform.ResourceAttrDiff{Old:"", New:"f61214b6-7477-46ac-b3c2-e1548de3f242", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"tf-bwide-etl-dpp-axi-prod", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "tags.%":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_address":*terraform.ResourceAttrDiff{Old:"", New:"10.109.40.12", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "template":*terraform.ResourceAttrDiff{Old:"", New:"AXI-CentOS-7-x86_64-Minimal", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "group":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "service_offering":*terraform.ResourceAttrDiff{Old:"", New:"4vCPU-8GB-SSD-STD-SF", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "expunge":*terraform.ResourceAttrDiff{Old:"", New:"true", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "keypair":*terraform.ResourceAttrDiff{Old:"", New:"bastion-axidpp-prod", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
...
...
20module.bwide-etl.cloudstack_instance.ci_simple: Creating...
display_name: "" => "<computed>"
expunge: "" => "true"
group: "" => "<computed>"
ip_address: "" => "10.109.40.12"
keypair: "" => "bastion-axidpp-prod"
name: "" => "tf-bwide-etl-dpp-axi-prod"
network_id: "" => "f61214b6-7477-46ac-b3c2-e1548de3f242"
project: "" => "<computed>"
root_disk_size: "" => "20"
service_offering: "" => "4vCPU-8GB-SSD-STD-SF"
tags.%: "" => "<computed>"
template: "" => "AXI-CentOS-7-x86_64-Minimal"
user_data: "" => "fc53581e3bca48406e504baba280a56c4d6dd0d0"
2018-04-26T11:14:22.015+0200 [DEBUG] plugin.terraform-provider-cloudstack_v0.1.4_x4: 2018/04/26 11:14:22 [DEBUG] Retrieving ID of service_offering: 4vCPU-8GB-SSD-STD-SF
zone: "" => "swiss1"
2018-04-26T11:14:22.081+0200 [DEBUG] plugin.terraform-provider-cloudstack_v0.1.4_x4: 2018/04/26 11:14:22 [DEBUG] Retrieving ID of zone: swiss1
2018-04-26T11:14:22.132+0200 [DEBUG] plugin.terraform-provider-cloudstack_v0.1.4_x4: 2018/04/26 11:14:22 [DEBUG] Retrieving ID of template: AXI-CentOS-7-x86_64-Minimal
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (10s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (20s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (30s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (40s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (50s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m0s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m10s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m20s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m30s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m40s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (1m50s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (2m0s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (2m10s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (2m20s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Still creating... (2m30s elapsed)
module.bwide-etl.cloudstack_instance.ci_simple: Creation complete after 2m32s (ID: 551bfafe-16a0-48a1-803f-be54ea6ef647)
2018/04/26 11:27:52 [DEBUG] Starting graph walk: walkPlan
2018/04/26 11:27:52 [TRACE] dag/walk: added new vertex: "provider.cloudstack"
2018/04/26 11:27:52 [TRACE] dag/weResourceInstance
2018/04/26 11:27:52 [DEBUG] ReferenceTransformer: "module.bwide-etl.cloudstack_instance.ci_simple" references: []
2018/04/26 11:27:52 [TRACE] Graph after step *terraform.ReferenceTransformer:
module.bwide-etl.cloudstack_instance.ci_simple - *terraform.NodePlannableResourceInstance
2018/04/26 11:27:52 [TRACE] Graph after step *terraform.RootTransformer:
module.bwide-etl.cloudstack_instance.ci_simple - *terraform.NodePlannableResourceInstance
2018/04/26 11:27:52 [TRACE] dag/walk: added new vertex: "module.bwide-etl.cloudstack_instance.ci_simple"
2018/04/26 11:27:52 [TRACE] dag/walk: walking "module.bwide-etl.cloudstack_instance.ci_simple"
2018/04/26 11:27:52 [TRACE] vertex 'root.bwide-etl.module.bwide-etl.cloudstack_instance.ci_simple': walking
2018/04/26 11:27:52 [TRACE] root.crifch-etl: eval: *terraform.EvalIf
2018/04/26 11:27:52 [TRACE] root.crifch-etl: eval: *terraform.EvalIf, err: early exit
2018/04/26 11:27:52 [TRACE] root.crifch-etl: eval: *terraform.EvalSequence, err: early exit
2018/04/26 11:27:52 [TRACE] [walkPlan] Exiting eval tree: module.crifch-etl.data.template_cloudinit_config.config
2018/04/26 11:27:52 [TRACE] dag/walk: walking "provider.template (close)"
2018/04/26 11:27:52 [TRACE] vertex 'root.provider.template (close)': walking
2018/04/26 11:27:52 [TRACE] dag/walk: walking "module.crifch-etl.cloudstack_instance.ci_simple"
2018/04/26 11:27:52 [TRACE] vertex 'root.provider.template (close)': evaluating
2018/04/26 11:27:52 [TRACE] [walkPlan] Entering eval tree: provider.template (close)
2018/04/26 11:27:52 [TRACE] vertex 'root.module.crifch-etl.cloudstack_instance.ci_simple': walking
2018/04/26 11:27:52 [TRACE] vertex 'root.bwide-etl.module.bwide-etl.cloudstack_instance.ci_simple': evaluating
2018/04/26 11:27:52 [TRACE] root: eval: *terraform.EvalCloseProvider
2018/04/26 11:27:52 [TRACE] [walkPlan] Entering eval tree: module.bwide-etl.cloudstack_instance.ci_simple
2018/04/26 11:27:52 [TRACE] root.bwide-etl: eval: *terraform.EvalSequence
2018/04/26 11:27:52 [TRACE] root.bwide-etl:
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ module.bwide-etl.cloudstack_instance.ci_simple (new resource required)
id: "551bfafe-16a0-48a1-803f-be54ea6ef647" => <computed> (forces new resource)
display_name: "tf-bwide-etl-dpp-axi-prod" => <computed>
expunge: "true" => "true"
group: "" => <computed>
ip_address: "10.109.40.12" => "10.109.40.12"
keypair: "bastion-axidpp-prod" => "bastion-axidpp-prod"
name: "tf-bwide-etl-dpp-axi-prod" => "tf-bwide-etl-dpp-axi-prod"
network_id: "f61214b6-7477-46ac-b3c2-e1548de3f242" => "f61214b6-7477-46ac-b3c2-e1548de3f242"
project: "" => <computed>
root_disk_size: "21474836480" => "20" (forces new resource)
service_offering: "4vCPU-8GB-SSD-STD-SF" => "4vCPU-8GB-SSD-STD-SF"
tags.%: "0" => <computed>
template: "AXI-CentOS-7-x86_64-Minimal" => "AXI-CentOS-7-x86_64-Minimal"
user_data: "fc53581e3bca48406e504baba280a56c4d6dd0d0" => "fc53581e3bca48406e504baba280a56c4d6dd0d0"
zone: "swiss1" => "swiss1"
Plan: 1 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
After applying following plan a instance is created successfully. But when listing the plan again (as shown belo) the root_size_disk
value changes its format from GB to Bytes which follows to an inconsistency between the code and the terraform state.
The expected behavior is that the terraform state keeps the value of the created instance in GB. And that every time that the state is refreshed root_disk_size
value remains as defined in the code.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.template_file.user_data: Refreshing state...
data.template_file.user_data: Refreshing state...
data.template_cloudinit_config.config: Refreshing state...
data.template_cloudinit_config.config: Refreshing state...
cloudstack_instance.ci_simple: Refreshing state... (ID: fcaf31b4-8c7b-4b3f-9083-2b9c2ad94b41)
cloudstack_disk.crifch-etl-data: Refreshing state... (ID: 6b609ec5-9550-445f-8214-f93b059ab8b9)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ module.bwide-etl.cloudstack_instance.ci_simple
id: <computed>
display_name: <computed>
expunge: "true"
group: <computed>
ip_address: "10.109.40.12"
keypair: "bastion-axidpp-prod"
name: "tf-bwide-etl-dpp-axi-prod"
network_id: "f61214b6-7477-46ac-b3c2-e1548de3f242"
project: <computed>
root_disk_size: "20"
service_offering: "4vCPU-8GB-SSD-STD-SF"
tags.%: <computed>
template: "AXI-CentOS-7-x86_64-Minimal"
user_data: "fc53581e3bca48406e504baba280a56c4d6dd0d0"
zone: "swiss1"
Plan: 1 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.template_file.user_data: Refreshing state...
data.template_file.user_data: Refreshing state...
data.template_cloudinit_config.config: Refreshing state...
data.template_cloudinit_config.config: Refreshing state...
cloudstack_instance.ci_simple: Refreshing state... (ID: 551bfafe-16a0-48a1-803f-be54ea6ef647)
cloudstack_instance.ci_simple: Refreshing state... (ID: fcaf31b4-8c7b-4b3f-9083-2b9c2ad94b41)
cloudstack_disk.crifch-etl-data: Refreshing state... (ID: 6b609ec5-9550-445f-8214-f93b059ab8b9)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ module.bwide-etl.cloudstack_instance.ci_simple (new resource required)
id: "551bfafe-16a0-48a1-803f-be54ea6ef647" => <computed> (forces new resource)
display_name: "tf-bwide-etl-dpp-axi-prod" => <computed>
expunge: "true" => "true"
group: "" => <computed>
ip_address: "10.109.40.12" => "10.109.40.12"
keypair: "bastion-axidpp-prod" => "bastion-axidpp-prod"
name: "tf-bwide-etl-dpp-axi-prod" => "tf-bwide-etl-dpp-axi-prod"
network_id: "f61214b6-7477-46ac-b3c2-e1548de3f242" => "f61214b6-7477-46ac-b3c2-e1548de3f242"
project: "" => <computed>
root_disk_size: "21474836480" => "20" (forces new resource)
service_offering: "4vCPU-8GB-SSD-STD-SF" => "4vCPU-8GB-SSD-STD-SF"
tags.%: "0" => <computed>
template: "AXI-CentOS-7-x86_64-Minimal" => "AXI-CentOS-7-x86_64-Minimal"
user_data: "fc53581e3bca48406e504baba280a56c4d6dd0d0" => "fc53581e3bca48406e504baba280a56c4d6dd0d0"
zone: "swiss1" => "swiss1"
Plan: 1 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.