Skip to content

Commit 815496e

Browse files
committed
Tuned documentation for databricks_instance_profile
1 parent 8e20d21 commit 815496e

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Added initial support for multiple task orchestration in `databricks_job` [#853](https://github.com/databrickslabs/terraform-provider-databricks/pull/853)
66
* Fixed provider crash for new terraform states related to bug [#813](https://github.com/hashicorp/terraform-plugin-sdk/issues/813) in Terraform SDK v2.8.0 ([#854](https://github.com/databrickslabs/terraform-provider-databricks/issues/854))
7+
* Re-added `skip_validation` to `databricks_instance_profile` resource [#762](https://github.com/databrickslabs/terraform-provider-databricks/issues/762)
8+
* Removed direct dependency on `aws-sdk-go`.
79

810
Updated dependency versions:
911

docs/resources/instance_profile.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,15 @@ resource "databricks_group_instance_profile" "all" {
108108
The following arguments are supported:
109109

110110
* `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.
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).
112+
* `skip_validation` - (Optional) **For advanced usage only.** 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.
113113

114114
## Attribute Reference
115115

116116
In addition to all arguments above, the following attributes are exported:
117117

118118
* `id` - ARN for EC2 Instance Profile, that is registered with Databricks.
119119

120-
121120
## Import
122121

123122
The resource instance profile can be imported using the ARN of it

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/Azure/go-autorest/autorest/adal v0.9.16
88
github.com/Azure/go-autorest/autorest/azure/auth v0.5.8
99
github.com/Azure/go-autorest/autorest/azure/cli v0.4.3
10-
github.com/aws/aws-sdk-go v1.40.54
1110
github.com/google/go-querystring v1.1.0
1211
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1312
github.com/hashicorp/go-retryablehttp v0.7.0

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
101101
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
102102
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
103103
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
104+
github.com/aws/aws-sdk-go v1.25.3 h1:uM16hIw9BotjZKMZlX05SN2EFtaWfi/NonPKIARiBLQ=
104105
github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
105106
github.com/aws/aws-sdk-go v1.40.54 h1:8zYzK8wI06G2+Bg2hwTUwzIYCCo6/Wd7lfS0G+GwqXU=
106107
github.com/aws/aws-sdk-go v1.40.54/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
@@ -304,6 +305,7 @@ github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c
304305
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
305306
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
306307
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
308+
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
307309
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
308310
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
309311
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
@@ -505,6 +507,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
505507
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
506508
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
507509
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
510+
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420 h1:a8jGStKg0XqKDlKqjLrXn0ioF5MH36pT7Z0BRTqLhbk=
508511
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
509512
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
510513
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=

identity/resource_instance_profile.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/aws/aws-sdk-go/aws/arn"
1211
"github.com/databrickslabs/terraform-provider-databricks/common"
1312

1413
"github.com/hashicorp/go-cty/cty"
@@ -21,7 +20,7 @@ import (
2120
type InstanceProfileInfo struct {
2221
InstanceProfileArn string `json:"instance_profile_arn,omitempty"`
2322
IsMetaInstanceProfile bool `json:"is_meta_instance_profile,omitempty"`
24-
SkipValidation bool `json:"skip_validation,omitempty"`
23+
SkipValidation bool `json:"skip_validation,omitempty" tf:"computed"`
2524
}
2625

2726
// InstanceProfileList ...
@@ -179,17 +178,26 @@ func ValidInstanceProfile(v interface{}, c cty.Path) diag.Diagnostics {
179178
},
180179
}
181180
}
182-
instanceProfileArn, err := arn.Parse(s)
183-
if err != nil {
181+
if !strings.HasPrefix(s, "arn:") {
182+
return diag.Diagnostics{
183+
diag.Diagnostic{
184+
AttributePath: c,
185+
Summary: "Invalid ARN",
186+
Detail: "Invalid prefix",
187+
},
188+
}
189+
}
190+
arnSections := strings.SplitN(s, ":", 6)
191+
if len(arnSections) != 6 {
184192
return diag.Diagnostics{
185193
diag.Diagnostic{
186194
AttributePath: c,
187195
Summary: "Invalid ARN",
188-
Detail: err.Error(),
196+
Detail: "Incorrect number of sections",
189197
},
190198
}
191199
}
192-
if !strings.HasPrefix(instanceProfileArn.Resource, "instance-profile") {
200+
if !strings.HasPrefix(arnSections[5], "instance-profile") {
193201
return diag.Diagnostics{
194202
diag.Diagnostic{
195203
AttributePath: c,

storage/aws_s3_mount.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"strings"
77

8-
"github.com/aws/aws-sdk-go/aws/arn"
98
"github.com/databrickslabs/terraform-provider-databricks/common"
109
"github.com/databrickslabs/terraform-provider-databricks/compute"
1110
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -117,11 +116,12 @@ func preprocessS3Mount(ctx context.Context, d *schema.ResourceData, m interface{
117116
// GetOrCreateMountingClusterWithInstanceProfile ...
118117
func GetOrCreateMountingClusterWithInstanceProfile(
119118
clustersAPI compute.ClustersAPI, instanceProfile string) (i compute.ClusterInfo, err error) {
120-
ia, err := arn.Parse(instanceProfile)
121-
if err != nil {
122-
return i, err
119+
arnSections := strings.SplitN(instanceProfile, ":", 6)
120+
if len(arnSections) != 6 {
121+
err = fmt.Errorf("invalid arn: %s", instanceProfile)
122+
return
123123
}
124-
instanceProfileParts := strings.Split(ia.Resource, "/")
124+
instanceProfileParts := strings.Split(arnSections[5], "/")
125125
clusterName := fmt.Sprintf("terraform-mount-%s", strings.Join(instanceProfileParts[1:], "-"))
126126
return clustersAPI.GetOrCreateRunningCluster(clusterName, compute.Cluster{
127127
NumWorkers: 1,

storage/aws_s3_mount_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestResourceAwsS3MountCreate_invalid_arn(t *testing.T) {
8484
},
8585
Create: true,
8686
}.Apply(t)
87-
require.EqualError(t, err, "arn: invalid prefix")
87+
require.EqualError(t, err, "invalid arn: this_mount")
8888
}
8989

9090
func TestResourceAwsS3MountRead(t *testing.T) {

0 commit comments

Comments
 (0)