@@ -22,6 +22,14 @@ func TestAccAWSAuthBackendSTSRole_import(t *testing.T) {
22
22
accountID := strconv .Itoa (acctest .RandInt ())
23
23
arn := acctest .RandomWithPrefix ("arn:aws:iam::" + accountID + ":role/test-role" )
24
24
externalID := "external-id"
25
+
26
+ importStateVerifyIgnore := make ([]string , 0 )
27
+ meta := testProvider .Meta ().(* provider.ProviderMeta )
28
+ // Ignore external_id if Vault version is < 1.17.0.
29
+ if ! meta .IsAPISupported (provider .VaultVersion117 ) {
30
+ importStateVerifyIgnore = append (importStateVerifyIgnore , consts .FieldExternalID )
31
+ }
32
+
25
33
resource .Test (t , resource.TestCase {
26
34
PreCheck : func () { testutil .TestAccPreCheck (t ) },
27
35
ProviderFactories : providerFactories ,
@@ -32,9 +40,10 @@ func TestAccAWSAuthBackendSTSRole_import(t *testing.T) {
32
40
Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , arn ),
33
41
},
34
42
{
35
- ResourceName : "vault_aws_auth_backend_sts_role.role" ,
36
- ImportState : true ,
37
- ImportStateVerify : true ,
43
+ ResourceName : "vault_aws_auth_backend_sts_role.role" ,
44
+ ImportState : true ,
45
+ ImportStateVerify : true ,
46
+ ImportStateVerifyIgnore : importStateVerifyIgnore ,
38
47
},
39
48
},
40
49
})
@@ -56,13 +65,18 @@ func TestAccAWSAuthBackendSTSRole_basic(t *testing.T) {
56
65
Config : testAccAWSAuthBackendSTSRoleConfig_basic (backend , accountID , arn , "" ),
57
66
Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , arn ),
58
67
},
68
+ {
69
+ // Update ARN.
70
+ Config : testAccAWSAuthBackendSTSRoleConfig_basic (backend , accountID , updatedArn , "" ),
71
+ Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , updatedArn ),
72
+ },
59
73
{
60
74
// Add external ID.
61
- Config : testAccAWSAuthBackendSTSRoleConfig_basic (backend , accountID , arn , externalID ),
62
- Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , arn ),
75
+ Config : testAccAWSAuthBackendSTSRoleConfig_basic (backend , accountID , updatedArn , externalID ),
76
+ Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , updatedArn ),
63
77
},
64
78
{
65
- // Update ARN and external ID.
79
+ // Update external ID.
66
80
Config : testAccAWSAuthBackendSTSRoleConfig_basic (backend , accountID , updatedArn , updatedExternalID ),
67
81
Check : testAccAWSAuthBackendSTSRoleCheck_attrs (backend , accountID , updatedArn ),
68
82
},
@@ -130,9 +144,14 @@ func testAccAWSAuthBackendSTSRoleCheck_attrs(backend, accountID, stsRole string)
130
144
}
131
145
132
146
attrs := map [string ]string {
133
- "sts_role" : "sts_role" ,
134
- consts .FieldExternalID : consts .FieldExternalID ,
147
+ "sts_role" : "sts_role" ,
148
+ }
149
+ meta := testProvider .Meta ().(* provider.ProviderMeta )
150
+ // Only check external_id if Vault version is >= 1.17.0
151
+ if meta .IsAPISupported (provider .VaultVersion117 ) {
152
+ attrs [consts .FieldExternalID ] = consts .FieldExternalID
135
153
}
154
+
136
155
for stateAttr , apiAttr := range attrs {
137
156
if resp .Data [apiAttr ] == nil && instanceState .Attributes [stateAttr ] == "" {
138
157
continue
0 commit comments