Skip to content

Commit

Permalink
Merge pull request #23815 from bschaatsbergen/add-protobuf-as-support…
Browse files Browse the repository at this point in the history
…ed-glue-schema-data-format

Update docs to refelect `PROTOBUF` as a supported `data_format` for the `aws_glue_schema` resource
  • Loading branch information
ewbankkit committed Mar 23, 2022
2 parents e32d638 + 9243d55 commit 265a59e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/23815.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_schema: Update documentation to include [Protobuf data format support](https://aws.amazon.com/about-aws/whats-new/2022/02/aws-glue-schema-registry-protocol-buffers)
```
41 changes: 41 additions & 0 deletions internal/service/glue/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ func TestAccGlueSchema_json(t *testing.T) {
})
}

func TestAccGlueSchema_protobuf(t *testing.T) {
var schema glue.GetSchemaOutput

rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_glue_schema.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); testAccPreCheckSchema(t) },
ErrorCheck: acctest.ErrorCheck(t, glue.EndpointsID),
Providers: acctest.Providers,
CheckDestroy: testAccCheckSchemaDestroy,
Steps: []resource.TestStep{
{
Config: testAccSchemaProtobufConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckSchemaExists(resourceName, &schema),
resource.TestCheckResourceAttr(resourceName, "data_format", "PROTOBUF"),
resource.TestCheckResourceAttr(resourceName, "schema_definition", "syntax = \"proto2\";\n\npackage tutorial;\n\noption java_multiple_files = true;\noption java_package = \"com.example.tutorial.protos\";\noption java_outer_classname = \"AddressBookProtos\";\n\nmessage Person {\n optional string name = 1;\n optional int32 id = 2;\n optional string email = 3;\n\n enum PhoneType {\n MOBILE = 0;\n HOME = 1;\n WORK = 2;\n }\n\n message PhoneNumber {\n optional string number = 1;\n optional PhoneType type = 2 [default = HOME];\n }\n\n repeated PhoneNumber phones = 4;\n}\n\nmessage AddressBook {\n repeated Person people = 1;\n}"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccGlueSchema_description(t *testing.T) {
var schema glue.GetSchemaOutput

Expand Down Expand Up @@ -413,6 +442,18 @@ resource "aws_glue_schema" "test" {
`, rName)
}

func testAccSchemaProtobufConfig(rName string) string {
return testAccSchemaBase(rName) + fmt.Sprintf(`
resource "aws_glue_schema" "test" {
schema_name = %[1]q
registry_arn = aws_glue_registry.test.arn
data_format = "PROTOBUF"
compatibility = "NONE"
schema_definition = "syntax = \"proto2\";\n\npackage tutorial;\n\noption java_multiple_files = true;\noption java_package = \"com.example.tutorial.protos\";\noption java_outer_classname = \"AddressBookProtos\";\n\nmessage Person {\n optional string name = 1;\n optional int32 id = 2;\n optional string email = 3;\n\n enum PhoneType {\n MOBILE = 0;\n HOME = 1;\n WORK = 2;\n }\n\n message PhoneNumber {\n optional string number = 1;\n optional PhoneType type = 2 [default = HOME];\n }\n\n repeated PhoneNumber phones = 4;\n}\n\nmessage AddressBook {\n repeated Person people = 1;\n}"
}
`, rName)
}

func testAccSchemaTags1Config(rName, tagKey1, tagValue1 string) string {
return testAccSchemaBase(rName) + fmt.Sprintf(`
resource "aws_glue_schema" "test" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/glue_schema.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following arguments are supported:

* `schema_name` – (Required) The Name of the schema.
* `registry_arn` - (Required) The ARN of the Glue Registry to create the schema in.
* `data_format` - (Required) The data format of the schema definition. Valid values are `AVRO` and `JSON`.
* `data_format` - (Required) The data format of the schema definition. Valid values are `AVRO`, `JSON` and `PROTOBUF`.
* `compatibility` - (Required) The compatibility mode of the schema. Values values are: `NONE`, `DISABLED`, `BACKWARD`, `BACKWARD_ALL`, `FORWARD`, `FORWARD_ALL`, `FULL`, and `FULL_ALL`.
* `schema_definition` - (Required) The schema definition using the `data_format` setting for `schema_name`.
* `description` – (Optional) A description of the schema.
Expand Down

0 comments on commit 265a59e

Please sign in to comment.