| layout | cloudstack |
|---|---|
| page_title | CloudStack: cloudstack_security_group |
| sidebar_current | docs-cloudstack-resource-security-group |
| description | Creates a security group. |
Creates a security group.
resource "cloudstack_security_group" "default" {
name = "allow_web"
description = "Allow access to HTTP and HTTPS"
}data "cloudstack_domain" "my_domain" {
filter {
name = "name"
value = "ROOT"
}
}
resource "cloudstack_security_group" "account_sg" {
name = "allow_web"
description = "Allow access to HTTP and HTTPS"
account = "my-account"
domainid = data.cloudstack_domain.my_domain.id
}resource "cloudstack_project" "my_project" {
name = "my-project"
displaytext = "My Project"
}
resource "cloudstack_security_group" "project_sg" {
name = "allow_web"
description = "Allow access to HTTP and HTTPS"
projectid = cloudstack_project.my_project.id
}The following arguments are supported:
-
name- (Required) The name of the security group. Changing this forces a new resource to be created. -
description- (Optional) The description of the security group. Changing this forces a new resource to be created. -
account- (Optional) The account name to create the security group for. Must be used withdomainid. Cannot be used withprojectid. Changing this forces a new resource to be created. -
domainid- (Optional) The name or ID of the domain to create this security group in. Changing this forces a new resource to be created. -
projectid- (Optional) The name or ID of the project to create this security group in. Cannot be used withaccount. Changing this forces a new resource to be created.
The following attributes are exported:
id- The ID of the security group.
Security groups can be imported; use <SECURITY GROUP ID> as the import ID. For
example:
terraform import cloudstack_security_group.default e54970f1-f563-46dd-a365-2b2e9b78c54bWhen importing into a project you need to prefix the import ID with the project name:
terraform import cloudstack_security_group.default my-project/e54970f1-f563-46dd-a365-2b2e9b78c54b