Commit 3ce61607 authored by Anton Babenko's avatar Anton Babenko

Cleanup after #74

parent 9efeb021
# Complete Security Group example # Complete Security Group example
Configuration in this directory creates set of Security Group and Security Group Rules resources in various combination. Configuration in this directory creates set of Security Group and Security Group Rules resources in various combinations.
Data sources are used to discover existing VPC resources (VPC and default security group). Data sources are used to discover existing VPC resources (VPC and default security group).
......
...@@ -357,3 +357,19 @@ module "ipv4_ipv6_example" { ...@@ -357,3 +357,19 @@ module "ipv4_ipv6_example" {
}, },
] ]
} }
#################################
# Security group with fixed name
#################################
module "fixed_name_sg" {
source = "../../"
name = "fixed-name-sg"
description = "Security group with fixed name"
vpc_id = "${data.aws_vpc.default.id}"
use_name_prefix = false
ingress_cidr_blocks = ["10.10.0.0/16"]
ingress_rules = ["https-443-tcp"]
}
# Complete Security Group example
Configuration in this directory creates set of Security Group and Security Group Rules resources in various combination.
Data sources are used to discover existing VPC resources (VPC and default security group).
## Usage
To run this example you need to execute:
```bash
$ terraform init
$ terraform plan
$ terraform apply
```
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Outputs
| Name | Description |
|------|-------------|
| this_security_group_description | The description of the security group |
| this_security_group_id | The ID of the security group |
| this_security_group_name | The name of the security group |
| this_security_group_owner_id | The owner ID |
| this_security_group_vpc_id | The VPC ID |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
provider "aws" {
region = "eu-west-1"
}
#############################################################
# Data sources to get VPC and default security group details
#############################################################
data "aws_vpc" "default" {
default = true
}
data "aws_security_group" "default" {
name = "default"
vpc_id = "${data.aws_vpc.default.id}"
}
##################################
# Security group with a fixed name
##################################
module "fixed_name_sg" {
source = "../../"
name = "fixed-name-sg"
description = "Security group with a fixed name and minimal rules"
use_name_prefix = "false"
vpc_id = "${data.aws_vpc.default.id}"
tags = {
Cash = "king"
Department = "kingdom"
}
# Default CIDR blocks, which will be used for all ingress rules in this module. Typically these are CIDR blocks of the VPC.
# If this is not specified then no CIDR blocks will be used.
ingress_cidr_blocks = ["10.10.0.0/16"]
# Open for all CIDRs defined in ingress_cidr_blocks
ingress_rules = ["https-443-tcp"]
# Open for self (rule or from_port+to_port+protocol+description)
ingress_with_self = [
{
rule = "all-all"
},
]
# Default CIDR blocks, which will be used for all egress rules in this module. Typically these are CIDR blocks of the VPC.
# If this is not specified then no CIDR blocks will be used.
egress_cidr_blocks = ["10.10.0.0/16"]
# Open for self (rule or from_port+to_port+protocol+description)
egress_with_self = [
{
rule = "all-all"
},
]
}
output "this_security_group_id" {
description = "The ID of the security group"
value = "${module.fixed_name_sg.this_security_group_id}"
}
output "this_security_group_vpc_id" {
description = "The VPC ID"
value = "${module.fixed_name_sg.this_security_group_vpc_id}"
}
output "this_security_group_owner_id" {
description = "The owner ID"
value = "${module.fixed_name_sg.this_security_group_owner_id}"
}
output "this_security_group_name" {
description = "The name of the security group"
value = "${module.fixed_name_sg.this_security_group_name}"
}
output "this_security_group_description" {
description = "The description of the security group"
value = "${module.fixed_name_sg.this_security_group_description}"
}
...@@ -15,8 +15,8 @@ variable "name" { ...@@ -15,8 +15,8 @@ variable "name" {
} }
variable "use_name_prefix" { variable "use_name_prefix" {
default = "true"
description = "Whether to use name_prefix or fixed name. Should be true to able to update security group name after initial creation" description = "Whether to use name_prefix or fixed name. Should be true to able to update security group name after initial creation"
default = true
} }
variable "description" { variable "description" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment