Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add arn attribute to aws_codedeploy_deployment_config #35888

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading