From b4c00b598de8ace7ecd2a2f11e416e641d33541c Mon Sep 17 00:00:00 2001 From: aki takami Date: Tue, 20 Feb 2024 11:47:42 +0900 Subject: [PATCH 1/3] [feat] add arn attribute to aws_codedeploy_deployment_config --- internal/service/deploy/deployment_config.go | 15 +++++++++++++++ internal/service/deploy/deployment_config_test.go | 1 + .../r/codedeploy_deployment_config.html.markdown | 1 + 3 files changed, 17 insertions(+) diff --git a/internal/service/deploy/deployment_config.go b/internal/service/deploy/deployment_config.go index c9aa3c7dfd3..1f6465de14b 100644 --- a/internal/service/deploy/deployment_config.go +++ b/internal/service/deploy/deployment_config.go @@ -5,9 +5,11 @@ package deploy import ( "context" + "fmt" "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 +34,10 @@ func resourceDeploymentConfig() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, "compute_platform": { Type: schema.TypeString, Optional: true, @@ -171,6 +177,15 @@ 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: fmt.Sprintf("deploymentconfig:%s", 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) diff --git a/internal/service/deploy/deployment_config_test.go b/internal/service/deploy/deployment_config_test.go index 85fcf3096fa..9fa0645d78f 100644 --- a/internal/service/deploy/deployment_config_test.go +++ b/internal/service/deploy/deployment_config_test.go @@ -37,6 +37,7 @@ func TestAccDeployDeploymentConfig_basic(t *testing.T) { Config: testAccDeploymentConfigConfig_fleet(rName, 75), Check: resource.ComposeTestCheckFunc( testAccCheckDeploymentConfigExists(ctx, resourceName, &config1), + acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "codedeploy", fmt.Sprintf("deploymentconfig:%s", rName)), 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 From 3985ca2ecec7515414a14c24a3c6b5c07d07a880 Mon Sep 17 00:00:00 2001 From: aki takami Date: Tue, 20 Feb 2024 12:24:01 +0900 Subject: [PATCH 2/3] [docs] add changelog --- .changelog/35888.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/35888.txt 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 +``` From 9c039e99bcf258b28642a3007ba3ada870d72038 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 20 Feb 2024 07:53:42 -0500 Subject: [PATCH 3/3] Tweaks. --- internal/service/deploy/deployment_config.go | 5 ++--- internal/service/deploy/deployment_config_test.go | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/service/deploy/deployment_config.go b/internal/service/deploy/deployment_config.go index 1f6465de14b..be8dc2b400e 100644 --- a/internal/service/deploy/deployment_config.go +++ b/internal/service/deploy/deployment_config.go @@ -5,7 +5,6 @@ package deploy import ( "context" - "fmt" "log" "github.com/aws/aws-sdk-go-v2/aws" @@ -183,12 +182,12 @@ func resourceDeploymentConfigRead(ctx context.Context, d *schema.ResourceData, m Service: "codedeploy", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, - Resource: fmt.Sprintf("deploymentconfig:%s", deploymentConfigName), + 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 9fa0645d78f..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,8 +36,8 @@ func TestAccDeployDeploymentConfig_basic(t *testing.T) { { Config: testAccDeploymentConfigConfig_fleet(rName, 75), Check: resource.ComposeTestCheckFunc( - testAccCheckDeploymentConfigExists(ctx, resourceName, &config1), - acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "codedeploy", fmt.Sprintf("deploymentconfig:%s", rName)), + 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"),