Skip to content

Commit

Permalink
Properties static_ip and subnet_id are optional in resource arm_redis…
Browse files Browse the repository at this point in the history
…_cache
  • Loading branch information
dominik-lekse committed Jan 31, 2018
1 parent 4f72433 commit e1c97ca
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions azurerm/resource_arm_redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error
resGroup := d.Get("resource_group_name").(string)

enableNonSSLPort := d.Get("enable_non_ssl_port").(bool)
staticIP := d.Get("static_ip").(string)
subnetID := d.Get("subnet_id").(string)

capacity := int32(d.Get("capacity").(int))
family := redis.SkuFamily(d.Get("family").(string))
Expand All @@ -231,12 +229,20 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error
Name: sku,
},
RedisConfiguration: expandRedisConfiguration(d),
StaticIP: &staticIP,
SubnetID: &subnetID,
},
Tags: expandedTags,
}

if v, ok := d.GetOk("static_ip"); ok {
staticIp := v.(string)
parameters.CreateProperties.StaticIP = &staticIp
}

if v, ok := d.GetOk("subnet_id"); ok {
subnetId := v.(string)
parameters.CreateProperties.SubnetID = &subnetId
}

if v, ok := d.GetOk("shard_count"); ok {
shardCount := int32(v.(int))
parameters.ShardCount = &shardCount
Expand Down Expand Up @@ -299,9 +305,6 @@ func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error
family := redis.SkuFamily(d.Get("family").(string))
sku := redis.SkuName(d.Get("sku_name").(string))

staticIP := d.Get("static_ip").(string)
subnetID := d.Get("subnet_id").(string)

tags := d.Get("tags").(map[string]interface{})
expandedTags := expandTags(tags)

Expand All @@ -313,12 +316,20 @@ func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error
Family: family,
Name: sku,
},
StaticIP: &staticIP,
SubnetID: &subnetID,
},
Tags: expandedTags,
}

if v, ok := d.GetOk("static_ip"); ok {
staticIp := v.(string)
parameters.UpdateProperties.StaticIP = &staticIp
}

if v, ok := d.GetOk("subnet_id"); ok {
subnetId := v.(string)
parameters.UpdateProperties.SubnetID = &subnetId
}

if v, ok := d.GetOk("shard_count"); ok {
if d.HasChange("shard_count") {
shardCount := int32(v.(int))
Expand Down

0 comments on commit e1c97ca

Please sign in to comment.