Added self option to security groups
This commit is contained in:
parent
79e5c419c3
commit
42fb14f19a
|
@ -69,6 +69,11 @@ func resourceComputeSecGroupV2() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: false,
|
||||
},
|
||||
"self": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -209,13 +214,17 @@ func resourceSecGroupRulesV2(d *schema.ResourceData) []secgroups.CreateRuleOpts
|
|||
createRuleOptsList := make([]secgroups.CreateRuleOpts, len(rawRules))
|
||||
for i, raw := range rawRules {
|
||||
rawMap := raw.(map[string]interface{})
|
||||
groupId := rawMap["from_group_id"].(string)
|
||||
if rawMap["self"].(bool) {
|
||||
groupId = d.Id()
|
||||
}
|
||||
createRuleOptsList[i] = secgroups.CreateRuleOpts{
|
||||
ParentGroupID: d.Id(),
|
||||
FromPort: rawMap["from_port"].(int),
|
||||
ToPort: rawMap["to_port"].(int),
|
||||
IPProtocol: rawMap["ip_protocol"].(string),
|
||||
CIDR: rawMap["cidr"].(string),
|
||||
FromGroupID: rawMap["from_group_id"].(string),
|
||||
FromGroupID: groupId,
|
||||
}
|
||||
}
|
||||
return createRuleOptsList
|
||||
|
@ -223,13 +232,17 @@ func resourceSecGroupRulesV2(d *schema.ResourceData) []secgroups.CreateRuleOpts
|
|||
|
||||
func resourceSecGroupRuleCreateOptsV2(d *schema.ResourceData, raw interface{}) secgroups.CreateRuleOpts {
|
||||
rawMap := raw.(map[string]interface{})
|
||||
groupId := rawMap["from_group_id"].(string)
|
||||
if rawMap["self"].(bool) {
|
||||
groupId = d.Id()
|
||||
}
|
||||
return secgroups.CreateRuleOpts{
|
||||
ParentGroupID: d.Id(),
|
||||
FromPort: rawMap["from_port"].(int),
|
||||
ToPort: rawMap["to_port"].(int),
|
||||
IPProtocol: rawMap["ip_protocol"].(string),
|
||||
CIDR: rawMap["cidr"].(string),
|
||||
FromGroupID: rawMap["from_group_id"].(string),
|
||||
FromGroupID: groupId,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,10 +59,13 @@ this creates a new security group rule.
|
|||
will be the source of network traffic to the security group. Use 0.0.0.0./0
|
||||
to allow all IP addresses. Changing this creates a new security group rule.
|
||||
|
||||
* `from_group_id - (Optional) Required if `cidr` is empty. The ID of a group
|
||||
* `from_group_id` - (Optional) Required if `cidr` is empty. The ID of a group
|
||||
from which to forward traffic to the parent group. Changing
|
||||
this creates a new security group rule.
|
||||
|
||||
* `self` - (Optional) Required if `cidr` and `from_group_id` is empty. If true,
|
||||
the security group itself will be added as a source to this ingress rule.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
The following attributes are exported:
|
||||
|
|
Loading…
Reference in New Issue