66 "testing"
77
88 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+ "github.com/hashicorp/terraform-plugin-testing/terraform"
910)
1011
1112func TestAccIntegrationResource (t * testing.T ) {
@@ -17,15 +18,15 @@ func TestAccIntegrationResource(t *testing.T) {
1718 if deployProfile == "" {
1819 t .Skip ("AUTOMQ_TEST_DEPLOY_PROFILE must be set for this test" )
1920 }
20- endpoint := os .Getenv ("AUTOMQ_TEST_BYOC_ENDPOINT " )
21+ endpoint := os .Getenv ("AUTOMQ_BYOC_ENDPOINT " )
2122 if endpoint == "" {
22- t .Skip ("AUTOMQ_TEST_BYOC_ENDPOINT must be set for this test" )
23+ t .Skip ("AUTOMQ_BYOC_ENDPOINT must be set for this test" )
2324 }
24- accessKeyId := os .Getenv ("AUTOMQ_TEST_BYOC_ACCESS_KEY_ID " )
25+ accessKeyId := os .Getenv ("AUTOMQ_BYOC_ACCESS_KEY_ID " )
2526 if accessKeyId == "" {
2627 t .Skip ("AUTOMQ_TEST_BYOC_ACCESS_KEY_ID must be set for this test" )
2728 }
28- secretKey := os .Getenv ("AUTOMQ_TEST_BYOC_SECRET_KEY " )
29+ secretKey := os .Getenv ("AUTOMQ_BYOC_SECRET_KEY " )
2930 if secretKey == "" {
3031 t .Skip ("AUTOMQ_TEST_BYOC_SECRET_KEY must be set for this test" )
3132 }
@@ -56,6 +57,18 @@ func TestAccIntegrationResource(t *testing.T) {
5657 ResourceName : "automq_integration.test_prometheus" ,
5758 ImportState : true ,
5859 ImportStateVerify : true ,
60+ ImportStateIdFunc : func (s * terraform.State ) (string , error ) {
61+ rs , ok := s .RootModule ().Resources ["automq_integration.test_prometheus" ]
62+ if ! ok {
63+ return "" , fmt .Errorf ("Not found: %s" , "automq_integration.test_prometheus" )
64+ }
65+ id := fmt .Sprintf ("%s@%s" , rs .Primary .Attributes ["environment_id" ], rs .Primary .Attributes ["id" ])
66+ return id , nil
67+ },
68+ ImportStateVerifyIgnore : []string {
69+ "created_at" ,
70+ "last_updated" ,
71+ },
5972 },
6073 // Update testing
6174 {
@@ -147,7 +160,7 @@ resource "automq_integration" "test_cloudwatch" {
147160 deploy_profile = %[2]q
148161 name = "test-cloudwatch"
149162 type = "cloudWatch"
150- cloudwatch_config {
163+ cloudwatch_config = {
151164 namespace = "AutoMQ/Test"
152165 }
153166}
0 commit comments