diff --git a/.changelog/35888.txt b/.changelog/35888.txt new file mode 100644 index 00000000000..91d7f035851 --- /dev/null +++ b/.changelog/35888.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_codedeploy_deployment_config: Add `arn` attribute +``` diff --git a/internal/service/deploy/deployment_config.go b/internal/service/deploy/deployment_config.go index c9aa3c7dfd3..be8dc2b400e 100644 --- a/internal/service/deploy/deployment_config.go +++ b/internal/service/deploy/deployment_config.go @@ -8,6 +8,7 @@ import ( "log" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/codedeploy" "github.com/aws/aws-sdk-go-v2/service/codedeploy/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -32,6 +33,10 @@ func resourceDeploymentConfig() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, "compute_platform": { Type: schema.TypeString, Optional: true, @@ -171,9 +176,18 @@ func resourceDeploymentConfigRead(ctx context.Context, d *schema.ResourceData, m return sdkdiag.AppendErrorf(diags, "reading CodeDeploy Deployment Config (%s): %s", d.Id(), err) } + deploymentConfigName := aws.ToString(deploymentConfig.DeploymentConfigName) + arn := arn.ARN{ + Partition: meta.(*conns.AWSClient).Partition, + Service: "codedeploy", + Region: meta.(*conns.AWSClient).Region, + AccountID: meta.(*conns.AWSClient).AccountID, + Resource: "deploymentconfig:" + deploymentConfigName, + }.String() + d.Set("arn", arn) d.Set("compute_platform", deploymentConfig.ComputePlatform) d.Set("deployment_config_id", deploymentConfig.DeploymentConfigId) - d.Set("deployment_config_name", deploymentConfig.DeploymentConfigName) + d.Set("deployment_config_name", deploymentConfigName) if err := d.Set("minimum_healthy_hosts", flattenMinimumHealthHosts(deploymentConfig.MinimumHealthyHosts)); err != nil { return sdkdiag.AppendErrorf(diags, "setting minimum_healthy_hosts: %s", err) } diff --git a/internal/service/deploy/deployment_config_test.go b/internal/service/deploy/deployment_config_test.go index 85fcf3096fa..bc41a500d63 100644 --- a/internal/service/deploy/deployment_config_test.go +++ b/internal/service/deploy/deployment_config_test.go @@ -23,7 +23,7 @@ import ( func TestAccDeployDeploymentConfig_basic(t *testing.T) { ctx := acctest.Context(t) - var config1 types.DeploymentConfigInfo + var config types.DeploymentConfigInfo resourceName := "aws_codedeploy_deployment_config.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -36,7 +36,8 @@ func TestAccDeployDeploymentConfig_basic(t *testing.T) { { Config: testAccDeploymentConfigConfig_fleet(rName, 75), Check: resource.ComposeTestCheckFunc( - testAccCheckDeploymentConfigExists(ctx, resourceName, &config1), + testAccCheckDeploymentConfigExists(ctx, resourceName, &config), + resource.TestCheckResourceAttrSet(resourceName, "arn"), resource.TestCheckResourceAttr(resourceName, "deployment_config_name", rName), resource.TestCheckResourceAttr(resourceName, "compute_platform", "Server"), resource.TestCheckResourceAttr(resourceName, "traffic_routing_config.#", "0"), diff --git a/website/docs/r/codedeploy_deployment_config.html.markdown b/website/docs/r/codedeploy_deployment_config.html.markdown index f573af528e8..8e7f1d4fbab 100644 --- a/website/docs/r/codedeploy_deployment_config.html.markdown +++ b/website/docs/r/codedeploy_deployment_config.html.markdown @@ -126,6 +126,7 @@ The `time_based_linear` block supports the following: This resource exports the following attributes in addition to the arguments above: +* `arn` - The ARN of the deployment config. * `id` - The deployment group's config name. * `deployment_config_id` - The AWS Assigned deployment config id