Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_lakeformation_resource: add hybrid_access_enabled argument #35571

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/35571.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_lakeformation_resource: Add `hybrid_access_enabled` argument
```
9 changes: 9 additions & 0 deletions internal/service/lakeformation/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func ResourceResource() *schema.Resource {
Optional: true,
ForceNew: true,
},
"hybrid_access_enabled": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
},
}
}
Expand All @@ -71,6 +76,10 @@ func resourceResourceCreate(ctx context.Context, d *schema.ResourceData, meta in
input.UseServiceLinkedRole = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("hybrid_access_enabled"); ok {
input.HybridAccessEnabled = aws.Bool(v.(bool))
}

_, err := conn.RegisterResourceWithContext(ctx, input)

if tfawserr.ErrCodeEquals(err, lakeformation.ErrCodeAlreadyExistsException) {
Expand Down
40 changes: 40 additions & 0 deletions internal/service/lakeformation/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,33 @@ func TestAccLakeFormationResource_updateSLRToRole(t *testing.T) {
})
}

func TestAccLakeFormationResource_hybridAccessEnabled(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceAddr := "aws_lakeformation_resource.test"
bucketAddr := "aws_s3_bucket.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, lakeformation.EndpointsID)
},
ErrorCheck: acctest.ErrorCheck(t, lakeformation.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckResourceDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccResourceConfig_hybridAccessEnabled(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckResourceExists(ctx, resourceAddr),
resource.TestCheckResourceAttrPair(resourceAddr, "arn", bucketAddr, "arn"),
resource.TestCheckResourceAttr(resourceAddr, "hybrid_access_enabled", "true"),
),
},
},
})
}

// AWS does not support changing from an IAM role to an SLR. No error is thrown
// but the registration is not changed (the IAM role continues in the registration).
//
Expand Down Expand Up @@ -310,3 +337,16 @@ resource "aws_lakeformation_resource" "test" {
}
`, rName)
}

func testAccResourceConfig_hybridAccessEnabled(rName string) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "test" {
bucket = %[1]q
}

resource "aws_lakeformation_resource" "test" {
arn = aws_s3_bucket.test.arn
hybrid_access_enabled = true
}
`, rName)
}
1 change: 1 addition & 0 deletions website/docs/r/lakeformation_resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following arguments are optional:

* `role_arn` – (Optional) Role that has read/write access to the resource.
* `use_service_linked_role` - (Optional) Designates an AWS Identity and Access Management (IAM) service-linked role by registering this role with the Data Catalog.
* `hybrid_access_enabled` - (Optional) Flag to enable AWS LakeFormation hybrid access permission mode.

~> **NOTE:** AWS does not support registering an S3 location with an IAM role and subsequently updating the S3 location registration to a service-linked role.

Expand Down
Loading