Skip to content

Commit

Permalink
Merge pull request #23341 from hashicorp/b-iso-ecs-include
Browse files Browse the repository at this point in the history
ecs/iso: Fix describe with configuration
  • Loading branch information
YakDriver authored Feb 23, 2022
2 parents b2715d5 + 565b804 commit 0619e62
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/23341.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ecs_cluster: Fix bug preventing describing clusters in ISO regions
```
6 changes: 3 additions & 3 deletions internal/service/ecs/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func resourceClusterCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(aws.StringValue(out.Cluster.ClusterArn))

if _, err := waitClusterAvailable(context.Background(), conn, d.Id()); err != nil {
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available: %w", d.Id(), err)
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available while creating: %w", d.Id(), err)
}

// Some partitions (i.e., ISO) may not support tag-on-create, attempt tag after create
Expand Down Expand Up @@ -345,7 +345,7 @@ func resourceClusterUpdate(d *schema.ResourceData, meta interface{}) error {
}

if _, err := waitClusterAvailable(context.Background(), conn, d.Id()); err != nil {
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available: %w", d.Id(), err)
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available while updating setting and configuration: %w", d.Id(), err)
}
}

Expand All @@ -363,7 +363,7 @@ func resourceClusterUpdate(d *schema.ResourceData, meta interface{}) error {
}

if _, err := waitClusterAvailable(context.Background(), conn, d.Id()); err != nil {
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available: %w", d.Id(), err)
return fmt.Errorf("error waiting for ECS Cluster (%s) to become Available while updating capacity_providers, default_capacity_provider_strategy: %w", d.Id(), err)
}
}

Expand Down
10 changes: 5 additions & 5 deletions internal/service/ecs/cluster_capacity_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func resourceClusterCapacityProvidersPut(ctx context.Context, d *schema.Resource
err := retryClusterCapacityProvidersPut(ctx, conn, input)

if err != nil {
return diag.Errorf("error updating ECS Cluster (%s) capacity providers: %s", clusterName, err)
return diag.Errorf("error updating ECS Cluster (%s) Capacity Providers: %s", clusterName, err)
}

if _, err := waitClusterAvailable(ctx, conn, clusterName); err != nil {
return diag.Errorf("error waiting for ECS Cluster (%s) to become available: %s", clusterName, err)
return diag.Errorf("error waiting for ECS Cluster (%s) to become available while putting Capacity Providers: %s", clusterName, err)
}

d.SetId(clusterName)
Expand Down Expand Up @@ -144,7 +144,7 @@ func resourceClusterCapacityProvidersDelete(ctx context.Context, d *schema.Resou
DefaultCapacityProviderStrategy: []*ecs.CapacityProviderStrategyItem{},
}

log.Printf("[DEBUG] Removing ECS cluster (%s) capacity providers", d.Id())
log.Printf("[DEBUG] Removing ECS Cluster (%s) Capacity Providers", d.Id())

err := retryClusterCapacityProvidersPut(ctx, conn, input)

Expand All @@ -153,11 +153,11 @@ func resourceClusterCapacityProvidersDelete(ctx context.Context, d *schema.Resou
}

if err != nil {
return diag.Errorf("error deleting ECS Cluster (%s) capacity providers: %s", d.Id(), err)
return diag.Errorf("error deleting ECS Cluster (%s) Capacity Providers: %s", d.Id(), err)
}

if _, err := waitClusterAvailable(ctx, conn, d.Id()); err != nil {
return diag.Errorf("error waiting for ECS Cluster (%s) to become available: %s", d.Id(), err)
return diag.Errorf("error waiting for ECS Cluster (%s) to become available while deleting Capacity Providers: %s", d.Id(), err)
}

return nil
Expand Down
10 changes: 9 additions & 1 deletion internal/service/ecs/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ func FindClusterByNameOrARN(ctx context.Context, conn *ecs.ECS, nameOrARN string

// Some partitions (i.e., ISO) may not support tagging, giving error
if verify.CheckISOErrorTagsUnsupported(err) {
log.Printf("[WARN] ECS tagging failed describing Cluster (%s) with tags: %s; retrying without tags", nameOrARN, err)
log.Printf("[WARN] failed describing ECS Cluster (%s) including tags: %s; retrying without tags", nameOrARN, err)

input.Include = aws.StringSlice([]string{ecs.ClusterFieldConfigurations, ecs.ClusterFieldSettings})
output, err = conn.DescribeClustersWithContext(ctx, input)
}

// Some partitions (i.e., ISO) may not support describe including configuration, giving error
if verify.CheckISOErrorTagsUnsupported(err) {
log.Printf("[WARN] failed describing ECS Cluster (%s) including configuration: %s; retrying without configuration", nameOrARN, err)

input.Include = aws.StringSlice([]string{ecs.ClusterFieldSettings})
output, err = conn.DescribeClustersWithContext(ctx, input)
}

if tfawserr.ErrCodeEquals(err, ecs.ErrCodeClusterNotFoundException) {
return nil, &resource.NotFoundError{
LastError: err,
Expand Down

0 comments on commit 0619e62

Please sign in to comment.