@@ -1119,41 +1119,79 @@ func TestAccCloudAutomatorJob_GoogleComputeInsertMachineImageAction(t *testing.T
11191119}
11201120
11211121func TestAccCloudAutomatorJob_GoogleComputeStartVmInstancesAction (t * testing.T ) {
1122- resourceName := "cloudautomator_job.test"
1123- jobName := fmt .Sprintf ("tf-testacc-job-%s" , utils .RandomString (12 ))
1124- postProcessId := acctest .TestPostProcessId ()
1125-
1126- resource .Test (t , resource.TestCase {
1127- PreCheck : func () { testAccPreCheck (t ) },
1128- ProviderFactories : testAccProviderFactories ,
1129- CheckDestroy : testAccCheckCloudAutomatorJobDestroy ,
1130- Steps : []resource.TestStep {
1131- {
1132- Config : testAccCheckCloudAutomatorJobConfigGoogleComputeStartVmInstancesAction (jobName ),
1133- Check : resource .ComposeTestCheckFunc (
1134- testAccCheckCloudAutomatorJobExists (testAccProviders ["cloudautomator" ], resourceName ),
1135- resource .TestCheckResourceAttr (
1136- resourceName , "name" , jobName ),
1137- resource .TestCheckResourceAttr (
1138- resourceName , "action_type" , "google_compute_start_vm_instances" ),
1139- resource .TestCheckResourceAttr (
1140- resourceName , "google_compute_start_vm_instances_action_value.0.region" , "asia-northeast1" ),
1141- resource .TestCheckResourceAttr (
1142- resourceName , "google_compute_start_vm_instances_action_value.0.project_id" , "example-project" ),
1143- resource .TestCheckResourceAttr (
1144- resourceName , "google_compute_start_vm_instances_action_value.0.specify_vm_instance" , "label" ),
1145- resource .TestCheckResourceAttr (
1146- resourceName , "google_compute_start_vm_instances_action_value.0.vm_instance_label_key" , "env" ),
1147- resource .TestCheckResourceAttr (
1148- resourceName , "google_compute_start_vm_instances_action_value.0.vm_instance_label_value" , "develop" ),
1149- resource .TestCheckResourceAttr (
1150- resourceName , "completed_post_process_id.0" , postProcessId ),
1151- resource .TestCheckResourceAttr (
1152- resourceName , "failed_post_process_id.0" , postProcessId ),
1153- ),
1154- },
1155- },
1156- })
1122+ resourceName := "cloudautomator_job.test"
1123+ jobName := fmt .Sprintf ("tf-testacc-job-%s" , utils .RandomString (12 ))
1124+ postProcessId := acctest .TestPostProcessId ()
1125+
1126+ resource .Test (t , resource.TestCase {
1127+ PreCheck : func () { testAccPreCheck (t ) },
1128+ ProviderFactories : testAccProviderFactories ,
1129+ CheckDestroy : testAccCheckCloudAutomatorJobDestroy ,
1130+ Steps : []resource.TestStep {
1131+ {
1132+ Config : testAccCheckCloudAutomatorJobConfigGoogleComputeStartVmInstancesAction (jobName ),
1133+ Check : resource .ComposeTestCheckFunc (
1134+ testAccCheckCloudAutomatorJobExists (testAccProviders ["cloudautomator" ], resourceName ),
1135+ resource .TestCheckResourceAttr (
1136+ resourceName , "name" , jobName ),
1137+ resource .TestCheckResourceAttr (
1138+ resourceName , "action_type" , "google_compute_start_vm_instances" ),
1139+ resource .TestCheckResourceAttr (
1140+ resourceName , "google_compute_start_vm_instances_action_value.0.region" , "asia-northeast1" ),
1141+ resource .TestCheckResourceAttr (
1142+ resourceName , "google_compute_start_vm_instances_action_value.0.project_id" , "example-project" ),
1143+ resource .TestCheckResourceAttr (
1144+ resourceName , "google_compute_start_vm_instances_action_value.0.specify_vm_instance" , "label" ),
1145+ resource .TestCheckResourceAttr (
1146+ resourceName , "google_compute_start_vm_instances_action_value.0.vm_instance_label_key" , "env" ),
1147+ resource .TestCheckResourceAttr (
1148+ resourceName , "google_compute_start_vm_instances_action_value.0.vm_instance_label_value" , "develop" ),
1149+ resource .TestCheckResourceAttr (
1150+ resourceName , "completed_post_process_id.0" , postProcessId ),
1151+ resource .TestCheckResourceAttr (
1152+ resourceName , "failed_post_process_id.0" , postProcessId ),
1153+ ),
1154+ },
1155+ },
1156+ })
1157+ }
1158+
1159+ func TestAccCloudAutomatorJob_GoogleComputeStopVmInstancesAction (t * testing.T ) {
1160+ resourceName := "cloudautomator_job.test"
1161+ jobName := fmt .Sprintf ("tf-testacc-job-%s" , utils .RandomString (12 ))
1162+ postProcessId := acctest .TestPostProcessId ()
1163+
1164+ resource .Test (t , resource.TestCase {
1165+ PreCheck : func () { testAccPreCheck (t ) },
1166+ ProviderFactories : testAccProviderFactories ,
1167+ CheckDestroy : testAccCheckCloudAutomatorJobDestroy ,
1168+ Steps : []resource.TestStep {
1169+ {
1170+ Config : testAccCheckCloudAutomatorJobConfigGoogleComputeStopVmInstancesAction (jobName ),
1171+ Check : resource .ComposeTestCheckFunc (
1172+ testAccCheckCloudAutomatorJobExists (testAccProviders ["cloudautomator" ], resourceName ),
1173+ resource .TestCheckResourceAttr (
1174+ resourceName , "name" , jobName ),
1175+ resource .TestCheckResourceAttr (
1176+ resourceName , "action_type" , "google_compute_stop_vm_instances" ),
1177+ resource .TestCheckResourceAttr (
1178+ resourceName , "google_compute_stop_vm_instances_action_value.0.region" , "asia-northeast1" ),
1179+ resource .TestCheckResourceAttr (
1180+ resourceName , "google_compute_stop_vm_instances_action_value.0.project_id" , "example-project" ),
1181+ resource .TestCheckResourceAttr (
1182+ resourceName , "google_compute_stop_vm_instances_action_value.0.specify_vm_instance" , "label" ),
1183+ resource .TestCheckResourceAttr (
1184+ resourceName , "google_compute_stop_vm_instances_action_value.0.vm_instance_label_key" , "env" ),
1185+ resource .TestCheckResourceAttr (
1186+ resourceName , "google_compute_stop_vm_instances_action_value.0.vm_instance_label_value" , "develop" ),
1187+ resource .TestCheckResourceAttr (
1188+ resourceName , "completed_post_process_id.0" , postProcessId ),
1189+ resource .TestCheckResourceAttr (
1190+ resourceName , "failed_post_process_id.0" , postProcessId ),
1191+ ),
1192+ },
1193+ },
1194+ })
11571195}
11581196
11591197func TestAccCloudAutomatorJob_InvokeLambdaFunctionAction (t * testing.T ) {
@@ -2806,24 +2844,46 @@ resource "cloudautomator_job" "test" {
28062844}
28072845
28082846func testAccCheckCloudAutomatorJobConfigGoogleComputeStartVmInstancesAction (rName string ) string {
2809- return fmt .Sprintf (`
2847+ return fmt .Sprintf (`
28102848resource "cloudautomator_job" "test" {
2811- name = "%s"
2812- group_id = "%s"
2813- google_cloud_account_id = "%s"
2849+ name = "%s"
2850+ group_id = "%s"
2851+ google_cloud_account_id = "%s"
28142852
2815- rule_type = "webhook"
2853+ rule_type = "webhook"
28162854
2817- action_type = "google_compute_start_vm_instances"
2818- google_compute_start_vm_instances_action_value {
2819- region = "asia-northeast1"
2820- project_id = "example-project"
2821- specify_vm_instance = "label"
2855+ action_type = "google_compute_start_vm_instances"
2856+ google_compute_start_vm_instances_action_value {
2857+ region = "asia-northeast1"
2858+ project_id = "example-project"
2859+ specify_vm_instance = "label"
28222860 vm_instance_label_key = "env"
2823- vm_instance_label_value = "develop"
2824- }
2825- completed_post_process_id = [%s]
2826- failed_post_process_id = [%s]
2861+ vm_instance_label_value = "develop"
2862+ }
2863+ completed_post_process_id = [%s]
2864+ failed_post_process_id = [%s]
2865+ }` , rName , acctest .TestGroupId (), acctest .TestGoogleCloudAccountId (), acctest .TestPostProcessId (), acctest .TestPostProcessId ())
2866+ }
2867+
2868+ func testAccCheckCloudAutomatorJobConfigGoogleComputeStopVmInstancesAction (rName string ) string {
2869+ return fmt .Sprintf (`
2870+ resource "cloudautomator_job" "test" {
2871+ name = "%s"
2872+ group_id = "%s"
2873+ google_cloud_account_id = "%s"
2874+
2875+ rule_type = "webhook"
2876+
2877+ action_type = "google_compute_stop_vm_instances"
2878+ google_compute_stop_vm_instances_action_value {
2879+ region = "asia-northeast1"
2880+ project_id = "example-project"
2881+ specify_vm_instance = "label"
2882+ vm_instance_label_key = "env"
2883+ vm_instance_label_value = "develop"
2884+ }
2885+ completed_post_process_id = [%s]
2886+ failed_post_process_id = [%s]
28272887}` , rName , acctest .TestGroupId (), acctest .TestGoogleCloudAccountId (), acctest .TestPostProcessId (), acctest .TestPostProcessId ())
28282888}
28292889
0 commit comments