Skip to content

Commit 8e20d21

Browse files
Allow to skip instance profile validation (#857)
1 parent 203d336 commit 8e20d21

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

docs/resources/instance_profile.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ resource "databricks_group_instance_profile" "all" {
107107

108108
The following arguments are supported:
109109

110-
* `instance_profile_arn` - (Required) `ARN` attribute of `aws_iam_instance_profile` output, the EC2 instance profile association to AWS IAM role. This ARN would be validated upon resource creation and it's not possible to skip validation.
111-
* `is_meta_instance_profile` - (Optional) Whether the instance profile is a meta instance profile. Used only in [IAM credential passthrough](https://docs.databricks.com/security/credential-passthrough/iam-passthrough.html).
110+
* `instance_profile_arn` - (Required) `ARN` attribute of `aws_iam_instance_profile` output, the EC2 instance profile association to AWS IAM role. This ARN would be validated upon resource creation.
111+
* `is_meta_instance_profile` - (Boolean, Optional) Whether the instance profile is a meta instance profile. Used only in [IAM credential passthrough](https://docs.databricks.com/security/credential-passthrough/iam-passthrough.html).
112+
* `skip_validation` - (Boolean, Optional, `false` by default) By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile. This validation uses AWS dry-run mode for the RunInstances API. If validation fails with an error message that does not indicate an IAM related permission issue, (e.g. “Your requested instance type is not supported in your requested availability zone”), you can pass this flag to skip the validation and forcibly add the instance profile.
112113

113114
## Attribute Reference
114115

identity/resource_instance_profile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
type InstanceProfileInfo struct {
2222
InstanceProfileArn string `json:"instance_profile_arn,omitempty"`
2323
IsMetaInstanceProfile bool `json:"is_meta_instance_profile,omitempty"`
24+
SkipValidation bool `json:"skip_validation,omitempty"`
2425
}
2526

2627
// InstanceProfileList ...

identity/resource_instance_profile_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,28 @@ func TestAwsAccInstanceProfiles(t *testing.T) {
203203
return true
204204
})
205205
}
206+
207+
func TestAwsAccInstanceProfilesSkippingValidation(t *testing.T) {
208+
arn := qa.GetEnvOrSkipTest(t, "TEST_EC2_INSTANCE_PROFILE")
209+
client := common.NewClientFromEnvironment()
210+
ctx := context.WithValue(context.Background(), common.Current, t.Name())
211+
instanceProfilesAPI := NewInstanceProfilesAPI(ctx, client)
212+
instanceProfilesAPI.Synchronized(arn, func() bool {
213+
err := instanceProfilesAPI.Create(InstanceProfileInfo{
214+
InstanceProfileArn: arn,
215+
SkipValidation: true,
216+
})
217+
if err != nil {
218+
return false
219+
}
220+
defer func() {
221+
err := instanceProfilesAPI.Delete(arn)
222+
assert.NoError(t, err, err)
223+
}()
224+
225+
arnSearch, err := instanceProfilesAPI.Read(arn)
226+
assert.NoError(t, err, err)
227+
assert.True(t, len(arnSearch.InstanceProfileArn) > 0)
228+
return true
229+
})
230+
}

0 commit comments

Comments
 (0)