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

Add support for Eventbridge Schema Registry, Discoverer and Schema resources #19100

Merged
merged 10 commits into from
May 26, 2021
11 changes: 11 additions & 0 deletions .changelog/19100.txt
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
```
6 changes: 5 additions & 1 deletion .changelog/19404.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ data-source/aws_msk_cluster: Add `bootstrap_brokers_sasl_iam` attribute
```

```release-note:enhancement
resource/aws_msk_cluster: Add `bootstrap_brokers_sasl_iam` argument
resource/aws_msk_cluster: Add `bootstrap_brokers_sasl_iam` attribute
```

```release-note:enhancement
resource/aws_msk_cluster: Add `iam` argument to `client_authentication.sasl` configuration block
```
4 changes: 4 additions & 0 deletions .github/labeler-pr-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@ service/sagemaker:
- 'aws/internal/service/sagemaker/**/*'
- '**/*_sagemaker_*'
- '**/sagemaker_*'
service/schemas:
- 'aws/internal/service/schemas/**/*'
- '**/*_schemas_*'
- '**/schemas_*'
service/secretsmanager:
- 'aws/internal/service/secretsmanager/**/*'
- '**/*_secretsmanager_*'
Expand Down
3 changes: 3 additions & 0 deletions .hashibot.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ behavior "regexp_issue_labeler_v2" "service_labels" {
"service/sagemaker" = [
"aws_sagemaker_",
],
"service/schemas" = [
"aws_schemas_",
],
"service/secretsmanager" = [
"aws_secretsmanager_",
],
Expand Down
3 changes: 3 additions & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3control"
"github.com/aws/aws-sdk-go/service/s3outposts"
"github.com/aws/aws-sdk-go/service/sagemaker"
"github.com/aws/aws-sdk-go/service/schemas"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/securityhub"
"github.com/aws/aws-sdk-go/service/serverlessapplicationrepository"
Expand Down Expand Up @@ -354,6 +355,7 @@ type AWSClient struct {
s3outpostsconn *s3outposts.S3Outposts
sagemakerconn *sagemaker.SageMaker
scconn *servicecatalog.ServiceCatalog
schemasconn *schemas.Schemas
sdconn *servicediscovery.ServiceDiscovery
secretsmanagerconn *secretsmanager.SecretsManager
securityhubconn *securityhub.SecurityHub
Expand Down Expand Up @@ -598,6 +600,7 @@ func (c *Config) Client() (interface{}, error) {
s3outpostsconn: s3outposts.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["s3outposts"])})),
sagemakerconn: sagemaker.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sagemaker"])})),
scconn: servicecatalog.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["servicecatalog"])})),
schemasconn: schemas.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["schemas"])})),
sdconn: servicediscovery.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["servicediscovery"])})),
secretsmanagerconn: secretsmanager.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["secretsmanager"])})),
securityhubconn: securityhub.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["securityhub"])})),
Expand Down
1 change: 1 addition & 0 deletions aws/internal/keyvaluetags/generators/listtags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ var serviceNames = []string{
"sagemaker",
"securityhub",
"servicediscovery",
"schemas",
"sfn",
"shield",
"signer",
Expand Down
1 change: 1 addition & 0 deletions aws/internal/keyvaluetags/generators/servicetags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ var mapServiceNames = []string{
"pinpoint",
"resourcegroups",
"securityhub",
"schemas",
"signer",
"sqs",
"synthetics",
Expand Down
1 change: 1 addition & 0 deletions aws/internal/keyvaluetags/generators/updatetags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var serviceNames = []string{
"secretsmanager",
"securityhub",
"servicediscovery",
"schemas",
"sfn",
"shield",
"signer",
Expand Down
18 changes: 18 additions & 0 deletions aws/internal/keyvaluetags/list_tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import (
"github.com/aws/aws-sdk-go/service/route53"
"github.com/aws/aws-sdk-go/service/route53resolver"
"github.com/aws/aws-sdk-go/service/sagemaker"
"github.com/aws/aws-sdk-go/service/schemas"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/securityhub"
"github.com/aws/aws-sdk-go/service/servicediscovery"
Expand Down Expand Up @@ -333,6 +334,8 @@ func ServiceClientType(serviceName string) string {
funcType = reflect.TypeOf(securityhub.New)
case "servicediscovery":
funcType = reflect.TypeOf(servicediscovery.New)
case "schemas":
funcType = reflect.TypeOf(schemas.New)
case "sfn":
funcType = reflect.TypeOf(sfn.New)
case "shield":
Expand Down
10 changes: 10 additions & 0 deletions aws/internal/keyvaluetags/service_tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions aws/internal/keyvaluetags/update_tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions aws/internal/service/schemas/finder/finder.go
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
}
25 changes: 25 additions & 0 deletions aws/internal/service/schemas/id.go
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)
}
4 changes: 4 additions & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,9 @@ func Provider() *schema.Provider {
"aws_sagemaker_notebook_instance_lifecycle_configuration": resourceAwsSagemakerNotebookInstanceLifeCycleConfiguration(),
"aws_sagemaker_notebook_instance": resourceAwsSagemakerNotebookInstance(),
"aws_sagemaker_user_profile": resourceAwsSagemakerUserProfile(),
"aws_schemas_discoverer": resourceAwsSchemasDiscoverer(),
"aws_schemas_registry": resourceAwsSchemasRegistry(),
"aws_schemas_schema": resourceAwsSchemasSchema(),
"aws_secretsmanager_secret": resourceAwsSecretsManagerSecret(),
"aws_secretsmanager_secret_policy": resourceAwsSecretsManagerSecretPolicy(),
"aws_secretsmanager_secret_version": resourceAwsSecretsManagerSecretVersion(),
Expand Down Expand Up @@ -1387,6 +1390,7 @@ func init() {
"s3control",
"s3outposts",
"sagemaker",
"schemas",
"sdb",
"secretsmanager",
"securityhub",
Expand Down
Loading