Created
April 13, 2016 11:50
-
-
Save Vidimensional/4bb02abd383f0aeb7be5652e5939c2e1 to your computer and use it in GitHub Desktop.
aws_db_security_group makes a modify on every subsequent plan/apply.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "access_key" { | |
type = "string" | |
} | |
variable "secret_key" { | |
type = "string" | |
} | |
provider "aws" { | |
access_key = "${var.access_key}" | |
secret_key = "${var.secret_key}" | |
region = "eu-west-1" | |
} | |
######################### | |
# | |
# EC2 autoscaling | |
# | |
resource "aws_autoscaling_group" "example" { | |
availability_zones = ["eu-west-1b"] | |
name = "autoscaling-example" | |
min_size = 0 | |
max_size = 5 | |
health_check_grace_period = 300 | |
health_check_type = "EC2" | |
launch_configuration = "${aws_launch_configuration.example.name}" | |
} | |
resource "aws_launch_configuration" "example" { | |
name_prefix = "test" | |
instance_type = "m1.small" | |
image_id = "ami-91ca6ae2" | |
user_data = "userdata.sh" | |
security_groups = ["${aws_security_group.example.name}"] | |
root_block_device { | |
volume_type = "gp2" | |
volume_size = 30 | |
delete_on_termination = true | |
} | |
lifecycle { | |
create_before_destroy = true | |
} | |
} | |
######################### | |
# | |
# EC2 security groups | |
# | |
resource "aws_security_group" "example" { | |
name = "example-sg" | |
} | |
resource "aws_security_group_rule" "example_ssh" { | |
type = "ingress" | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
security_group_id = "${aws_security_group.example.id}" | |
} | |
######################### | |
# | |
# RDS | |
# | |
resource "aws_db_instance" "postgres" { | |
identifier = "example-postgres" | |
engine = "postgres" | |
engine_version = "9.4.5" | |
instance_class = "db.m1.small" | |
multi_az = "False" | |
allocated_storage = 5 | |
username = "userexample" | |
password = "supersecure123" | |
security_group_names = ["${aws_db_security_group.postgres.name}"] | |
parameter_group_name = "${aws_db_parameter_group.postgres.name}" | |
} | |
resource "aws_db_parameter_group" "postgres" { | |
name = "postgres-paramgroup" | |
family = "postgres9.4" | |
description = "Parameter Group for PostgreSQL." | |
} | |
resource "aws_db_security_group" "postgres" { | |
name = "postgres-securitygroup" | |
description = "RDS PostgreSQL security group" | |
ingress { | |
security_group_id = "${aws_security_group.example.id}" | |
security_group_owner_id = "${aws_security_group.example.owner_id}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment