Difference between revisions of "Terraform resource: aws security group"
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
== Examples == | == Examples == | ||
+ | |||
+ | <pre> | ||
+ | resource "aws_security_group" "allow_ssh" { | ||
+ | name = "allow_ssh" | ||
+ | description = "Allow ssh inbound traffic from Internet" | ||
+ | |||
+ | ingress { | ||
+ | description = "SSH from Internet" | ||
+ | from_port = 22 | ||
+ | to_port = 22 | ||
+ | protocol = "tcp" | ||
+ | cidr_blocks = ["0.0.0.0/0"] | ||
+ | ipv6_cidr_blocks = ["::/0"] | ||
+ | } | ||
+ | |||
+ | tags = { | ||
+ | Name = "allow_ssh" | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | |||
resource "aws_security_group" "allow_tls" { | resource "aws_security_group" "allow_tls" { | ||
name = "allow_tls" | name = "allow_tls" |
Revision as of 09:03, 13 March 2023
Contents
Examples
resource "aws_security_group" "allow_ssh" { name = "allow_ssh" description = "Allow ssh inbound traffic from Internet" ingress { description = "SSH from Internet" from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] ipv6_cidr_blocks = ["::/0"] } tags = { Name = "allow_ssh" } }
resource "aws_security_group" "allow_tls" { name = "allow_tls" description = "Allow TLS inbound traffic" vpc_id = aws_vpc.main.id ingress { description = "TLS from VPC" from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = [aws_vpc.main.cidr_block] ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] ipv6_cidr_blocks = ["::/0"] } tags = { Name = "allow_tls" } }
Arguments
prefix_list_ids
(optional)
Related terms
- Terraform resource:
aws_security_group_rule
- Security group
vpc_id
security_groups, network_configuration
:aws_ecs_service
vpc_security_group_ids
:aws_instance, aws_db_instance
aws_network_interface_sg_attachment
aws_instance
See also
Advertising: