Skip to content

Instantly share code, notes, and snippets.

@robinbowes
Created October 6, 2017 11:51
Show Gist options
  • Save robinbowes/bde1c56585df284f924ee81b46a6061e to your computer and use it in GitHub Desktop.
Save robinbowes/bde1c56585df284f924ee81b46a6061e to your computer and use it in GitHub Desktop.
Example of terraform issue
provider "aws" {
region = "${var.aws_region}"
}
variable "aws_region" {
default = "eu-west-1"
}
variable "asg_max_size" {
default = "6"
}
variable "asg_min_size" {
default = "3"
}
variable "namespace" {
default = "mps"
}
variable "component" {
default = "foo"
}
variable "stage" {
default = "rbtest"
}
locals {
common_settings = [
{
namespace = "aws:autoscaling:asg"
name = "Availability Zones"
value = "Any"
},
{
namespace = "aws:autoscaling:asg"
name = "Cooldown"
value = "360"
},
]
specific_settings = [
{
namespace = "aws:autoscaling:asg"
name = "MaxSize"
value = "${var.asg_max_size}"
},
{
namespace = "aws:autoscaling:asg"
name = "MinSize"
value = "${var.asg_min_size}"
},
{
namespace = "aws:autoscaling:launchconfiguration"
name = "IamInstanceProfile"
value = "${aws_iam_instance_profile.instance.name}"
},
]
}
resource "aws_iam_instance_profile" "instance" {
name = "instance_profile"
path = "/"
role = "${aws_iam_role.instance.name}"
}
resource "aws_iam_role" "instance" {
name = "ec2-role"
path = "/"
assume_role_policy = "${data.aws_iam_policy_document.instance.json}"
}
data "aws_iam_policy_document" "instance" {
statement {
actions = [
"sts:AssumeRole",
]
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_elastic_beanstalk_environment" "foo" {
name = "foo"
application = "foo_app"
cname_prefix = "foo"
solution_stack_name = "64bit Amazon Linux 2017.03 v2.5.0 running PHP 7.1"
tier = "WebServer"
setting = "${concat(local.common_settings, local.specific_settings)}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment