From 9b8d173626f9bae08b458e9aa67c5ed9b3a44281 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 28 Mar 2024 08:29:34 -0400 Subject: [PATCH] r/aws_acmpca_permission: Corrections. --- internal/service/acmpca/permission.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/service/acmpca/permission.go b/internal/service/acmpca/permission.go index 26dba9b8312..0c6f1ade6e3 100644 --- a/internal/service/acmpca/permission.go +++ b/internal/service/acmpca/permission.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/acmpca" "github.com/aws/aws-sdk-go-v2/service/acmpca/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -79,7 +80,7 @@ func resourcePermissionCreate(ctx context.Context, d *schema.ResourceData, meta caARN := d.Get("certificate_authority_arn").(string) principal := d.Get("principal").(string) sourceAccount := d.Get("source_account").(string) - id := errs.Must(flex.FlattenResourceId([]string{caARN, principal, sourceAccount}, permissionResourceIDPartCount, false)) + id := errs.Must(flex.FlattenResourceId([]string{caARN, principal, sourceAccount}, permissionResourceIDPartCount, true)) input := &acmpca.CreatePermissionInput{ Actions: expandPermissionActions(d.Get("actions").(*schema.Set)), CertificateAuthorityArn: aws.String(caARN), @@ -105,7 +106,7 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ACMPCAClient(ctx) - parts, err := flex.ExpandResourceId(d.Id(), permissionResourceIDPartCount, false) + parts, err := flex.ExpandResourceId(d.Id(), permissionResourceIDPartCount, true) if err != nil { return sdkdiag.AppendFromErr(diags, err) } @@ -136,7 +137,7 @@ func resourcePermissionDelete(ctx context.Context, d *schema.ResourceData, meta var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ACMPCAClient(ctx) - parts, err := flex.ExpandResourceId(d.Id(), permissionResourceIDPartCount, false) + parts, err := flex.ExpandResourceId(d.Id(), permissionResourceIDPartCount, true) if err != nil { return sdkdiag.AppendFromErr(diags, err) } @@ -192,6 +193,13 @@ func findPermissions(ctx context.Context, conn *acmpca.Client, input *acmpca.Lis for pages.HasMorePages() { page, err := pages.NextPage(ctx) + if errs.IsAErrorMessageContains[*types.InvalidStateException](err, "The certificate authority is in the DELETED state") { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + if err != nil { return nil, err }