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

New Service: s3tables #40420

Merged
merged 35 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3b4e69f
Adds service S3 Tables
gdavison Nov 7, 2024
891b920
Adds `PrefixNoneOf` and `SuffixNoneOf` framework validators
gdavison Nov 7, 2024
394e4cf
Adds resource `aws_s3tables_table_bucket`
gdavison Nov 7, 2024
f3005ea
Updates `skaff` to use Finder functions in Exists and Destroy tests
gdavison Nov 8, 2024
ba56b11
`skaff`: Adds `ctx` parameter to `testAccPreCheck` call
gdavison Nov 8, 2024
b544c15
Removes unneeded indirection
gdavison Nov 9, 2024
7e61955
Adds resource `aws_s3tables_namespace`
gdavison Nov 9, 2024
8f015fd
Adds resource `aws_s3tables_table_bucket_policy`
gdavison Nov 13, 2024
7297aba
Adds sweeper for `aws_s3tables_table_bucket`
gdavison Nov 13, 2024
0a28a6b
Focuses semgrep message on offending import line
gdavison Nov 19, 2024
2fb0218
Adds resource `aws_s3tables_table`
gdavison Nov 20, 2024
5253a1a
Documentation tweaks
gdavison Nov 20, 2024
5dc2799
Adds sweepers for `aws_s3tables_namespace` and `aws_s3tables_table`
gdavison Nov 20, 2024
e9b03dd
Consolidates name validation
gdavison Nov 20, 2024
7ca5abb
Adds knownvalue check that takes any string-like value
gdavison Nov 21, 2024
35a2e59
Adds `maintenance_configuration` to `aws_s3tables_table_bucket`
gdavison Nov 22, 2024
059bb19
Adds `maintenance_configuration` to `aws_s3tables_table`
gdavison Nov 23, 2024
b2fa7a7
Corrects actions
gdavison Nov 23, 2024
ecef0ea
Adds identifier struct for namespace
gdavison Nov 23, 2024
5d119da
Adds `UseStateForUnknown` for table bucket `maintenance_configuration`
gdavison Nov 23, 2024
6fc0ee4
Updates table bucket `maintenance_configuration` to match table
gdavison Nov 23, 2024
17704dd
Adds resource `aws_s3tables_table_policy`
gdavison Nov 25, 2024
16da3e2
Cleanup
gdavison Nov 25, 2024
c80971f
Excludes flex functions from Semgrep rule
gdavison Nov 25, 2024
a2c50a7
Changes `aws_s3tables_namespace` `namespace` from list to string
gdavison Nov 26, 2024
709e4d8
Documentation cleanup
gdavison Nov 26, 2024
e4799a0
Use `noflatten` for `aws_s3tables_table` `Namespace`
gdavison Nov 27, 2024
6f801b5
Don't allocate Input structs on heap
gdavison Nov 27, 2024
a49f977
Adds CHANGELOG entry
gdavison Dec 3, 2024
41d327e
Corrects branding in documentation
gdavison Dec 3, 2024
4badbf5
Fixes `copyloopvar` linting errors
gdavison Dec 3, 2024
9cc60bf
`tfproviderdocs` doesn't treat newline and space as equivalent
gdavison Dec 3, 2024
b88c7ea
Removes deprecated variable interpolation
gdavison Dec 3, 2024
203a811
More `tfproviderdocs` doesn't treat newline and space as equivalent
gdavison Dec 3, 2024
533bd2c
Required phrasing
gdavison Dec 3, 2024
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
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
gdavison committed Dec 3, 2024
commit 16da3e20720c45ef8b2c7efe91e2b58e00ad3914
3 changes: 1 addition & 2 deletions internal/service/s3tables/table_bucket_policy.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ const (

type resourceTableBucketPolicy struct {
framework.ResourceWithConfigure
framework.WithTimeouts
}

func (r *resourceTableBucketPolicy) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
@@ -117,7 +116,7 @@ func (r *resourceTableBucketPolicy) Read(ctx context.Context, req resource.ReadR
}
if err != nil {
resp.Diagnostics.AddError(
create.ProblemStandardMessage(names.S3Tables, create.ErrActionSetting, ResNameTableBucketPolicy, state.TableBucketARN.String(), err),
create.ProblemStandardMessage(names.S3Tables, create.ErrActionReading, ResNameTableBucketPolicy, state.TableBucketARN.String(), err),
err.Error(),
)
return
7 changes: 2 additions & 5 deletions internal/service/s3tables/table_bucket_policy_test.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ func TestAccS3TablesTableBucketPolicy_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableBucketPolicyConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableBucketPolicyExists(ctx, resourceName, &tablebucketpolicy),
resource.TestCheckResourceAttrSet(resourceName, "resource_policy"),
resource.TestCheckResourceAttrPair(resourceName, "table_bucket_arn", "aws_s3tables_table_bucket.test", names.AttrARN),
@@ -59,9 +59,6 @@ func TestAccS3TablesTableBucketPolicy_basic(t *testing.T) {

func TestAccS3TablesTableBucketPolicy_disappears(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var tablebucketpolicy s3tables.GetTableBucketPolicyOutput
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
@@ -78,7 +75,7 @@ func TestAccS3TablesTableBucketPolicy_disappears(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableBucketPolicyConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableBucketPolicyExists(ctx, resourceName, &tablebucketpolicy),
acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfs3tables.NewResourceTableBucketPolicy, resourceName),
),
1 change: 0 additions & 1 deletion internal/service/s3tables/table_policy.go
Original file line number Diff line number Diff line change
@@ -189,7 +189,6 @@ func (r *resourceTablePolicy) Update(ctx context.Context, req resource.UpdateReq
func (r *resourceTablePolicy) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
conn := r.Meta().S3TablesClient(ctx)

// TIP: -- 2. Fetch the state
var state resourceTablePolicyModel
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
20 changes: 10 additions & 10 deletions internal/service/s3tables/table_test.go
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ func TestAccS3TablesTable_disappears(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableConfig_basic(rName, namespace, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfs3tables.NewResourceTable, resourceName),
),
@@ -162,7 +162,7 @@ func TestAccS3TablesTable_rename(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableConfig_basic(rName, namespace, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
),
@@ -177,7 +177,7 @@ func TestAccS3TablesTable_rename(t *testing.T) {
},
{
Config: testAccTableConfig_basic(rNameUpdated, namespace, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rNameUpdated),
resource.TestCheckResourceAttrSet(resourceName, "modified_at"),
@@ -243,7 +243,7 @@ func TestAccS3TablesTable_updateNamespace(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableConfig_basic(rName, namespace, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrNamespace, namespace),
),
@@ -258,7 +258,7 @@ func TestAccS3TablesTable_updateNamespace(t *testing.T) {
},
{
Config: testAccTableConfig_basic(rName, namespaceUpdated, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrNamespace, namespaceUpdated),
resource.TestCheckResourceAttrSet(resourceName, "modified_at"),
@@ -325,7 +325,7 @@ func TestAccS3TablesTable_updateNameAndNamespace(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccTableConfig_basic(rName, namespace, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, names.AttrNamespace, namespace),
@@ -341,7 +341,7 @@ func TestAccS3TablesTable_updateNameAndNamespace(t *testing.T) {
},
{
Config: testAccTableConfig_basic(rNameUpdated, namespaceUpdated, bucketName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rNameUpdated),
resource.TestCheckResourceAttr(resourceName, names.AttrNamespace, namespaceUpdated),
@@ -498,7 +498,7 @@ func testAccCheckTableExists(ctx context.Context, name string, table *s3tables.G
return create.Error(names.S3Tables, create.ErrActionCheckingExistence, tfs3tables.ResNameTable, name, errors.New("not found"))
}

if rs.Primary.Attributes["table_bucket_arn"] == "" || rs.Primary.Attributes[names.AttrName] == "" {
if rs.Primary.Attributes["table_bucket_arn"] == "" || rs.Primary.Attributes[names.AttrNamespace] == "" || rs.Primary.Attributes[names.AttrName] == "" {
return create.Error(names.S3Tables, create.ErrActionCheckingExistence, tfs3tables.ResNameTable, name, errors.New("not set"))
}

@@ -571,14 +571,14 @@ resource "aws_s3tables_table" "test" {
maintenance_configuration = {
iceberg_compaction = {
settings = {
target_file_size_mb = %[4]d
target_file_size_mb = %[4]d
}
status = "enabled"
}
iceberg_snapshot_management = {
settings = {
max_snapshot_age_hours = %[5]d
min_snapshots_to_keep = %[6]d
min_snapshots_to_keep = %[6]d
}
status = "enabled"
}
78 changes: 78 additions & 0 deletions website/docs/r/s3tables_table_policy.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
subcategory: "S3 Tables"
layout: "aws"
page_title: "AWS: aws_s3tables_table_policy"
description: |-
Terraform resource for managing an AWS S3 Tables Table Policy.
---

# Resource: aws_s3tables_table_policy

Terraform resource for managing an AWS S3 Tables Table Policy.

## Example Usage

### Basic Usage

```terraform
resource "aws_s3tables_table_policy" "example" {
resource_policy = data.aws_iam_policy_document.example.json
name = aws_s3tables_table.test.name
namespace = aws_s3tables_table.test.namespace
table_bucket_arn = aws_s3tables_table.test.table_bucket_arn
}

data "aws_iam_policy_document" "example" {
statement {
# ...
}
}

resource "aws_s3tables_table" "example" {
name = "example-table"
namespace = aws_s3tables_namespace.example
table_bucket_arn = aws_s3tables_namespace.example.table_bucket_arn
format = "ICEBERG"
}

resource "aws_s3tables_namespace" "example" {
namespace = ["example-namespace"]
table_bucket_arn = aws_s3tables_table_bucket.example.arn
}

resource "aws_s3tables_table_bucket" "example" {
name = "example-bucket"
}
```

## Argument Reference

The following arguments are required:

* `resource_policy` - (Required) Amazon Web Services resource-based policy document in JSON format.
* `name` - (Required, Forces new resource) Name of the table.
Must be between 1 and 255 characters in length.
Can consist of lowercase letters, numbers, and underscores, and must begin and end with a lowercase letter or number.
* `namespace` - (Required, Forces new resource) Name of the namespace for this table.
Must be between 1 and 255 characters in length.
Can consist of lowercase letters, numbers, and underscores, and must begin and end with a lowercase letter or number.
* `table_bucket_arn` - (Required, Forces new resource) ARN referencing the Table Bucket that contains this Namespace.

## Import

In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import S3 Tables Table Policy using the `table_bucket_arn`, the value of `namespace`, and the value of `name`, separated by a semicolon (`;`).
For example:

```terraform
import {
to = aws_s3tables_table_policy.example
id = "arn:aws:s3tables:us-west-2:123456789012:bucket/example-bucket;example-namespace;example-table"
}
```

Using `terraform import`, import S3 Tables Table Policy using the `table_bucket_arn`, the value of `namespace`, and the value of `name`, separated by a semicolon (`;`).
For example:

```console
% terraform import aws_s3tables_table_policy.example 'arn:aws:s3tables:us-west-2:123456789012:bucket/example-bucket;example-namespace;example-table'
```