Skip to content

Commit

Permalink
Merge pull request #11648 from terraform-providers/b-codedeploy-load-…
Browse files Browse the repository at this point in the history
…balancer

Addresses a number of issues with blocks in `aws_codedeploy_deployment_group`
  • Loading branch information
gdavison authored Feb 4, 2020
2 parents 1b47e7d + a0cd520 commit 326b393
Show file tree
Hide file tree
Showing 3 changed files with 915 additions and 969 deletions.
17 changes: 9 additions & 8 deletions aws/resource_aws_codedeploy_deployment_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ func resourceAwsCodeDeployDeploymentGroup() *schema.Resource {
},

"deployment_style": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Type: schema.TypeList,
Optional: true,
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"deployment_option": {
Type: schema.TypeString,
Optional: true,
Default: codedeploy.DeploymentOptionWithoutTrafficControl,
ValidateFunc: validation.StringInSlice([]string{
codedeploy.DeploymentOptionWithTrafficControl,
codedeploy.DeploymentOptionWithoutTrafficControl,
Expand All @@ -93,6 +94,7 @@ func resourceAwsCodeDeployDeploymentGroup() *schema.Resource {
"deployment_type": {
Type: schema.TypeString,
Optional: true,
Default: codedeploy.DeploymentTypeInPlace,
ValidateFunc: validation.StringInSlice([]string{
codedeploy.DeploymentTypeInPlace,
codedeploy.DeploymentTypeBlueGreen,
Expand Down Expand Up @@ -211,7 +213,6 @@ func resourceAwsCodeDeployDeploymentGroup() *schema.Resource {
"load_balancer_info": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1030,14 +1031,14 @@ func expandDeploymentStyle(list []interface{}) *codedeploy.DeploymentStyle {
}

// expandLoadBalancerInfo converts a raw schema list containing a map[string]interface{}
// into a single codedeploy.LoadBalancerInfo object
// into a single codedeploy.LoadBalancerInfo object. Returns an empty object if list is nil.
func expandLoadBalancerInfo(list []interface{}) *codedeploy.LoadBalancerInfo {
loadBalancerInfo := &codedeploy.LoadBalancerInfo{}
if len(list) == 0 || list[0] == nil {
return nil
return loadBalancerInfo
}

lbInfo := list[0].(map[string]interface{})
loadBalancerInfo := &codedeploy.LoadBalancerInfo{}

if attr, ok := lbInfo["elb_info"]; ok && attr.(*schema.Set).Len() > 0 {
loadBalancerInfo.ElbInfoList = expandCodeDeployElbInfo(attr.(*schema.Set).List())
Expand Down
Loading

0 comments on commit 326b393

Please sign in to comment.