Skip to content

Commit

Permalink
Add rolesanywhere/trust_anchor resource
Browse files Browse the repository at this point in the history
  • Loading branch information
mattburgess committed Jul 14, 2022
1 parent f79cc52 commit a078082
Show file tree
Hide file tree
Showing 9 changed files with 859 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/aws/aws-sdk-go-v2/service/kendra"
"github.com/aws/aws-sdk-go-v2/service/rolesanywhere"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go-v2/service/transcribe"
"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -198,6 +199,12 @@ func (c *Config) Client(ctx context.Context) (interface{}, diag.Diagnostics) {
}
})

client.RolesAnywhereConn = rolesanywhere.NewFromConfig(cfg, func(o *rolesanywhere.Options) {
if endpoint := c.Endpoints[names.RolesAnywhere]; endpoint != "" {
o.EndpointResolver = rolesanywhere.EndpointResolverFromURL(endpoint)
}
})

client.Route53DomainsConn = route53domains.NewFromConfig(cfg, func(o *route53domains.Options) {
if endpoint := c.Endpoints[names.Route53Domains]; endpoint != "" {
o.EndpointResolver = route53domains.EndpointResolverFromURL(endpoint)
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/service/redshiftdata"
"github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups"
"github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroupstaggingapi"
"github.com/hashicorp/terraform-provider-aws/internal/service/rolesanywhere"
"github.com/hashicorp/terraform-provider-aws/internal/service/route53"
"github.com/hashicorp/terraform-provider-aws/internal/service/route53domains"
"github.com/hashicorp/terraform-provider-aws/internal/service/route53recoverycontrolconfig"
Expand Down Expand Up @@ -1834,6 +1835,8 @@ func Provider() *schema.Provider {

"aws_resourcegroups_group": resourcegroups.ResourceGroup(),

"aws_rolesanywhere_trust_anchor": rolesanywhere.ResourceTrustAnchor(),

"aws_route53_delegation_set": route53.ResourceDelegationSet(),
"aws_route53_health_check": route53.ResourceHealthCheck(),
"aws_route53_hosted_zone_dnssec": route53.ResourceHostedZoneDNSSEC(),
Expand Down
38 changes: 38 additions & 0 deletions internal/service/rolesanywhere/find.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package rolesanywhere

import (
"context"
"errors"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/rolesanywhere"
"github.com/aws/aws-sdk-go-v2/service/rolesanywhere/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

func FindTrustAnchorByID(ctx context.Context, conn *rolesanywhere.Client, id string) (*rolesanywhere.GetTrustAnchorOutput, error) {
in := &rolesanywhere.GetTrustAnchorInput{
TrustAnchorId: aws.String(id),
}

out, err := conn.GetTrustAnchor(ctx, in)

var resourceNotFoundException *types.ResourceNotFoundException
if errors.As(err, &resourceNotFoundException) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: in,
}
}

if err != nil {
return nil, err
}

if out == nil {
return nil, tfresource.NewEmptyResultError(in)
}

return out, nil
}
4 changes: 4 additions & 0 deletions internal/service/rolesanywhere/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//go:generate go run ../../generate/tags/main.go -AwsSdkVersion=2 -ListTags -ServiceTagsSlice -UpdateTags
// ONLY generate directives and package declaration! Do not add anything else to this file.

package rolesanywhere
94 changes: 94 additions & 0 deletions internal/service/rolesanywhere/tags_gen.go

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

Loading

0 comments on commit a078082

Please sign in to comment.