-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19100 from jordanfinners/f-eventbridge-schemas
Add support for Eventbridge Schema Registry, Discoverer and Schema resources
- Loading branch information
Showing
28 changed files
with
2,020 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```release-note:new-resource | ||
aws_schemas_discoverer | ||
``` | ||
|
||
```release-note:new-resource | ||
aws_schemas_registry | ||
``` | ||
|
||
```release-note:new-resource | ||
aws_schemas_schema | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/schemas" | ||
"github.com/hashicorp/aws-sdk-go-base/tfawserr" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func DiscovererByID(conn *schemas.Schemas, id string) (*schemas.DescribeDiscovererOutput, error) { | ||
input := &schemas.DescribeDiscovererInput{ | ||
DiscovererId: aws.String(id), | ||
} | ||
|
||
output, err := conn.DescribeDiscoverer(input) | ||
|
||
if tfawserr.ErrCodeEquals(err, schemas.ErrCodeNotFoundException) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, &resource.NotFoundError{ | ||
Message: "Empty result", | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return output, nil | ||
} | ||
|
||
func RegistryByName(conn *schemas.Schemas, name string) (*schemas.DescribeRegistryOutput, error) { | ||
input := &schemas.DescribeRegistryInput{ | ||
RegistryName: aws.String(name), | ||
} | ||
|
||
output, err := conn.DescribeRegistry(input) | ||
|
||
if tfawserr.ErrCodeEquals(err, schemas.ErrCodeNotFoundException) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, &resource.NotFoundError{ | ||
Message: "Empty result", | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return output, nil | ||
} | ||
|
||
func SchemaByNameAndRegistryName(conn *schemas.Schemas, name, registryName string) (*schemas.DescribeSchemaOutput, error) { | ||
input := &schemas.DescribeSchemaInput{ | ||
RegistryName: aws.String(registryName), | ||
SchemaName: aws.String(name), | ||
} | ||
|
||
output, err := conn.DescribeSchema(input) | ||
|
||
if tfawserr.ErrCodeEquals(err, schemas.ErrCodeNotFoundException) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, &resource.NotFoundError{ | ||
Message: "Empty result", | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package transfer | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
const schemaResourceIDSeparator = "/" | ||
|
||
func SchemaCreateResourceID(schemaName, registryName string) string { | ||
parts := []string{schemaName, registryName} | ||
id := strings.Join(parts, schemaResourceIDSeparator) | ||
|
||
return id | ||
} | ||
|
||
func SchemaParseResourceID(id string) (string, string, error) { | ||
parts := strings.Split(id, schemaResourceIDSeparator) | ||
|
||
if len(parts) == 2 && parts[0] != "" && parts[1] != "" { | ||
return parts[0], parts[1], nil | ||
} | ||
|
||
return "", "", fmt.Errorf("unexpected format for ID (%[1]s), expected SCHEMA_NAME%[2]sREGISTRY_NAME", id, schemaResourceIDSeparator) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.