Skip to content

Commit

Permalink
Merge pull request #35888 from a-takamin/f-aws_codedeploy_deployment_…
Browse files Browse the repository at this point in the history
…config-add-arn

[feat] add arn attribute to aws_codedeploy_deployment_config
  • Loading branch information
ewbankkit authored Feb 20, 2024
2 parents 3665fd7 + 9c039e9 commit ddb77e8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/35888.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_codedeploy_deployment_config: Add `arn` attribute
```
16 changes: 15 additions & 1 deletion internal/service/deploy/deployment_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/service/deploy/deployment_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/codedeploy_deployment_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ddb77e8

Please sign in to comment.