#terraform - December 2018

December 2018
davidvasandani
davidvasandanialmost 8 years ago(edited)
Deploying cloudposse/terraform-aws-eks-cluster https://github.com/cloudposse/terraform-aws-eks-cluster/tree/master/examples/complete but running into the following errors:

module.eks_cluster.aws_security_group_rule.ingress_security_groups: aws_security_group_rule.ingress_security_groups: value of 'count' cannot be computed

module.eks_workers.module.autoscale_group.data.null_data_source.tags_as_list_of_maps: data.null_data_source.tags_as_list_of_maps: value of 'count' cannot be computed


I see that autoscale_group was updated https://github.com/cloudposse/terraform-aws-ec2-autoscale-group/pull/5 to use terraform-terraform-label which from searching the Slack history seemed to be an issue.

and eks_cluster is also failing at ingress_security_groups https://github.com/cloudposse/terraform-aws-eks-cluster/blob/master/main.tf#L69

I’m not passing in any tags or security group so the terraform-aws-eks-cluster module is just using the defaults.
davidvasandani
davidvasandanialmost 8 years ago
Yep. I’ve been going through that.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Ok :-)
davidvasandani
davidvasandanialmost 8 years ago
When targeting the eks_cluster module replacing:
allowed_security_groups = ["${distinct(compact(concat(var.allowed_security_groups_cluster, list(module.eks_workers.security_group_id))))}"]
with
allowed_security_groups = ["sg-09264f5790c8e28e1"] resolves the issue.

So right now I’m trying to target the eks_workers module.
davidvasandani
davidvasandanialmost 8 years ago
How do you correctly format the tag variable?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Andriy Knysh (Cloud Posse) we should have a Makefile in that example
davidvasandani
davidvasandanialmost 8 years ago
tags="map('environment','operations')"
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
No you can pass tags just like normal
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
A map
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Some places show it written using interpolation because it used to be that way in older versions of terraform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
And that got copied and pasted everywhere
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
I’ll have to check it again, when we tested a few months ago, we didn’t see those errors
davidvasandani
davidvasandanialmost 8 years ago
Passing in the tags while targeting the eks_workers module didn’t work.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Aside from the hard coding you did as a workaround, no other changes from the example?
davidvasandani
davidvasandanialmost 8 years ago(edited)
Commenting out the null_data_source all together when targeting the eks_workers module resolves the issue.

# data "null_data_source" "tags_as_list_of_maps" {
#   count = "${var.enabled == "true" ? length(keys(var.tags)) : 0}"
# 
#   inputs = "${map(
#     "key", "${element(keys(var.tags), count.index)}",
#     "value", "${element(values(var.tags), count.index)}",
#     "propagate_at_launch", true
#   )}"
# }

resource "aws_autoscaling_group" "default" {
  count = "${var.enabled == "true" ? 1 : 0}"

  name_prefix               = "${format("%s%s", module.label.id, var.delimiter)}"
  ...
  service_linked_role_arn   = "${var.service_linked_role_arn}"

  launch_template = {
    id      = "${join("", aws_launch_template.default.*.id)}"
    version = "${aws_launch_template.default.latest_version}"
  }

  # tags = ["${data.null_data_source.tags_as_list_of_maps.*.outputs}"]

  lifecycle {
    create_before_destroy = true
  }
}
davidvasandani
davidvasandanialmost 8 years ago
@Erik Osterman (Cloud Posse) no I tried to pass in minimal variables and use the eks module defaults.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
👍️
davidvasandani
davidvasandanialmost 8 years ago
With the null_data_source in eks_workers commented out I had hoped the full eks module would work (I reverted the eks_cluster allowed_security_groups back to the default) but eks_cluster still errors.


module.eks_cluster.aws_security_group_rule.ingress_security_groups: aws_security_group_rule.ingress_security_groups: value of 'count' cannot be computed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Unfortunately don’t know what is causing this. Seems like something has changed in terraform recently that breaks it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
On a serious note, on AWS use kops for Kubernetes
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We wrote these modules to evaluate the possibility of using EKS but consider terraform as not the right tool for the job
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
No automated rolling upgrades
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
No easy way to do drain and cordon
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
So from a lifecycle management perspective we only use kops with our customers
davidvasandani
davidvasandanialmost 8 years ago
Ah. Ok. Easy enough. Thanks @Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
There is also https://eksctl.io/
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
But it doesn’t help with upgrades yet either
davidvasandani
davidvasandanialmost 8 years ago
I’ve heard lots of great things about kops so I’ll just roll with that. The goal is to deploy the statup app and test namespacing per PR.
davidvasandani
davidvasandanialmost 8 years ago
Thanks for your help @Erik Osterman (Cloud Posse) @Andriy Knysh (Cloud Posse) 🙌🏻
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
np, sorry the EKS module didn’t work for you. We tested it many times, but it was a few months ago and we didn’t touch it since then. Those count errors are really annoying. Maybe HCL 2.0 will solve those issues
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Kops works really good for us
rohit
rohitalmost 8 years ago(edited)
Hi. I am facing some sort of issue with dns cert validation using cloudflare provider
rohit
rohitalmost 8 years ago
it works perfectly fine in a different tf module
rohit
rohitalmost 8 years ago
but fails in my compute module
rohit
rohitalmost 8 years ago
i am not able to figure out what's going on
rohit
rohitalmost 8 years ago
davidvasandani
davidvasandanialmost 8 years ago
@rohit what error are you receiving?
rohit
rohitalmost 8 years ago
* aws_alb_listener.my_app-443: Error creating LB Listener: CertificateNotFound: Certificate 'arn:aws:acm:us-east-1:011123456789:certificate/a7f83c2e-57c4-4046-b81a-f9a6fe153ad0' not found
	status code: 400, request id: 6c1234e8-f111-12e3-af9f-19f5bf9b2312
2018/12/01 11:41:44 [ERROR] root.compute.my_app: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_alb_listener.my_app-443: Error creating LB Listener: CertificateNotFound: Certificate 'arn:aws:acm:us-east-1:011123456789:certificate/a7f83c2e-57c4-4046-b81a-f9a6fe153ad0' not found
	status code: 400, request id: 6c1234e8-f111-12e3-af9f-19f5bf9b2312

Error: Error applying plan:

3 error(s) occurred:

* module.compute.module.my_app.cloudflare_record.my_app_cloudflare_public: 1 error(s) occurred:

* cloudflare_record.my_app_cloudflare_public: Error finding zone "<http://crs.org|crs.org>": ListZones command failed: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6103,\"message\":\"Invalid format for X-Auth-Key header\"}]}],\"messages\":[],\"result\":null}"
* module.compute.module.my_app.cloudflare_record.dns_cert_validation: 1 error(s) occurred:

* cloudflare_record.dns_cert_validation: Error finding zone "<http://crs.org|crs.org>": ListZones command failed: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6103,\"message\":\"Invalid format for X-Auth-Key header\"}]}],\"messages\":[],\"result\":null}"
* module.compute.module.my_app.aws_alb_listener.my_app-443: 1 error(s) occurred:

* aws_alb_listener.my_app-443: Error creating LB Listener: CertificateNotFound: Certificate 'arn:aws:acm:us-east-1:011123456789:certificate/a7f83c2e-57c4-4046-b81a-f9a6fe153ad0' not found
	status code: 400, request id: 6c1234e8-f111-12e3-af9f-19f5bf9b2312
rohit
rohitalmost 8 years ago
i replaced original values with dummy values but that's the error
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Seems that authentication doesn't work to cloudflare.
rohit
rohitalmost 8 years ago
i use similar code for dns validation in different module and it does work
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit you sure that Cloudflare owns the zone <http://crs.org|crs.org>? Name servers point to
IN	<http://ns13.dnsmadeeasy.com|ns13.dnsmadeeasy.com>.	86400
IN	<http://ns15.dnsmadeeasy.com|ns15.dnsmadeeasy.com>.	86400
IN	<http://ns11.dnsmadeeasy.com|ns11.dnsmadeeasy.com>.	86400
IN	<http://ns12.dnsmadeeasy.com|ns12.dnsmadeeasy.com>.	86400
IN	<http://ns10.dnsmadeeasy.com|ns10.dnsmadeeasy.com>.	86400
IN	<http://ns14.dnsmadeeasy.com|ns14.dnsmadeeasy.com>.	86400
rohit
rohitalmost 8 years ago
i replaced the original zone with a different value
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
kk 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
check if DNS works for the zone (name servers, etc.)
rohit
rohitalmost 8 years ago
using nslookup ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
any tool to read the records from the zone
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
or it’s just what it says Invalid format for X-Auth-Key header
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
somehow it worked now
rohit
rohitalmost 8 years ago
cert validation does take forever
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it usually takes up to 5 minutes
rohit
rohitalmost 8 years ago
yeah it does
rohit
rohitalmost 8 years ago
how do you perform dns cert validation ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
same DNS validation
rohit
rohitalmost 8 years ago
basically use route53 instead of cloudflare
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yes
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We recommend 2 types of domains
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
One is for infrastructure and service discovery
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
The other is for branded (aka vanity) domains
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Host vanity domains on CloudFlare
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
And CNAME those to your infra domains
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Ensure that Cloudflare is configured for end to end encryption
rohit
rohitalmost 8 years ago
@Erik Osterman (Cloud Posse) how can i ensure that it is configured for end to end encryption ?
rohit
rohitalmost 8 years ago
we do use https for all our connections and TLSv1.2
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
It’s a flag in their UI presumably exposed via API
rohit
rohitalmost 8 years ago
I am sure it is checked but i will double check
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I am on my phone so can’t screenshot it
rohit
rohitalmost 8 years ago
but i didn't understand how it is important in this context
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
It’s relative to our suggestion of creating 2 levels of domains
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Use ACM with route53 for service discovery domain
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Use Cloudflare with vanity domains
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Use end to end encryption to ensure privacy
rohit
rohitalmost 8 years ago
we do use route53 for internal services and use cloudflare for publicly exposed endpoints
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Just red flags go up for me if using Cloudflare to validate acm certificates
rohit
rohitalmost 8 years ago
because the name on the cert matches with the endpoint we have to use cloudflare to do the validation
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Ok
rohit
rohitalmost 8 years ago
Just curious, if we create internal alb, then then the only way to is to do email validation, correct ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
So I think that with Cloudflare things can work differently
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We are using route53 with acm on internal domain for docs.cloudposse.com
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Internal domain is .org
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We use DNS validation
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Then we use Cloudflare to cname that to the origin
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I am pretty certain we didn’t need the cert name to match because I don’t think CloudFlare is passthru
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Cloudflare requests the content from the origins and performs transformations on the content
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
E.g. compression and minificarion
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
It is not a simple reverse proxy
rohit
rohitalmost 8 years ago
after what you said, when i think about it i am not able to remember why we had to do it this way
rohit
rohitalmost 8 years ago
i will have to check with someone from OPS team
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
👍️
rohit
rohitalmost 8 years ago
did you see my above question ? because you are on phone i will paste it again
if we create internal alb, then then the only way to is to do email validation, correct ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Ohhhhhhhh I see
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Internal alb, so non routable
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Good question. I have not tried acm dns validation with internal domains, but that would make the most sense since there is no way for AWS to reach it due to the network isolation.
rohit
rohitalmost 8 years ago
we currently use email validation for internal alb but was not sure if that can be automated in terraform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Perhaps there are some work arounds where you allow some kind of AWS managed vpc endpoint to reach it kind of like you can do with Private S3 buckets
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
For example with classic ELBs we could allow some AWS managed security group access to the origin.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Now with this being a VPC not sure if they’ve done anything to accommodate it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Please let me know if you find a conclusive answer yes/no
rohit
rohitalmost 8 years ago
will do. I am trying to find more about this or any other alternative in terraform for internal alb
rohit
rohitalmost 8 years ago
we use full ssl option
rohit
rohitalmost 8 years ago
@Erik Osterman (Cloud Posse) my google terraform search for anything now returns one of your modules 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Lol yes we tend to do that...
rohit
rohitalmost 8 years ago
that's pretty awesome
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
As far as I know, there is no way to do email validation using TF. Maybe some third party tools exist
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) that's what i thought. so what happens when i pass validation_method = "EMAIL" to the aws_acm_certificate resource
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Aha you need to establish a private CA
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

Q: What are the benefits of using AWS Certificate Manager (ACM) and ACM Private Certificate Authority (CA)?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

ACM Private CA is a managed private CA service that helps you easily and securely manage the lifecycle of your private certificates. ACM Private CA provides you a highly-available private CA service without the upfront investment and ongoing maintenance costs of operating your own private CA.
rohit
rohitalmost 8 years ago
i think that would work
rohit
rohitalmost 8 years ago
i am assuming there is a terraform resource to create private cert
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yea let me know!
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago(edited)
That's a lot of effort for an internal network with SSL offloading by the ALB, meaning it ends up to be HTTP in the same network anyway.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
" curious, if we create internal alb, then then the only way to is to do email validation, correct ?"

That has nothing to do with it, as long as ACM can check if the CNAME resolves to the .aws-domain it will work out with creating the certificate.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago(edited)
Certificate creation is outside the scope of the module, as it's more likely to have one wildcard cert for many services
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Let's continue here Rohit, sub-threads confuse me 🙂
rohit
rohitalmost 8 years ago
i noticed that when i do terraform destory it destroys all the resources but the certificate manager still has the certs that were created by terraform. Is there flag that needs to be passed for it to destroy those certs ?
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
That's odd, are you 100% sure ?
rohit
rohitalmost 8 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
I saw the cert gets destroyed
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
maybe you can try and see if you can repeat that behaviour
rohit
rohitalmost 8 years ago
trying now
rohit
rohitalmost 8 years ago
Looks like it was just that one time
rohit
rohitalmost 8 years ago
when i tried again everything was destroyed gracefully
rohit
rohitalmost 8 years ago
i am trying to pass params to my userdata template,
data "template_file" "user-data" {
  template = "${file("${path.cwd}/modules/compute/user-data.sh.tpl")}"

  vars = {
    app_env               = "${terraform.workspace}"
    region_name           = "${local.aws_region}"
    chef_environment_name = "${local.get_chef_environment_name}"
  }
}
rohit
rohitalmost 8 years ago
and in my template, i have the following
export NODE_NAME="$$(app_env)app-$$(curl --silent --show-error --retry 3 <http://169.254.169.254/latest/meta-data/instance-id>)" # this uses the EC2 instance ID as the node name
rohit
rohitalmost 8 years ago
the app_env is not being evaluated
rohit
rohitalmost 8 years ago
it just stays as is
rohit
rohitalmost 8 years ago
is there anything wrong in my template ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
@rohit i think you need one $, not two, and curly braces
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the format is ${var}
rohit
rohitalmost 8 years ago
i tried that
rohit
rohitalmost 8 years ago(edited)
export NODE_NAME="$(app_env)app-$$(curl --silent --show-error --retry 3 <http://169.254.169.254/latest/meta-data/instance-id>)" # this uses the EC2 instance ID as the node name
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
curly braces
rohit
rohitalmost 8 years ago
yeah that was a silly mistake by me
rohit
rohitalmost 8 years ago
when i updated the template and ran terraform plan followed by terraform apply the userdata on the launch template did not get updated
rohit
rohitalmost 8 years ago
i am assuming it is because of the difference between tempalte vs resource
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yea those formats are different and often confusing, have to always look them up
rohit
rohitalmost 8 years ago
yeah. similarly, i always have to look up symlink syntax for source and destination 🙂
rohit
rohitalmost 8 years ago(edited)
I am using terraform-terraform-labeland terraform-aws-modules/vpc/aws module, i noticed that even though i have name = "VPC" in terraform-terraform-label it is converting it to lowercase
rohit
rohitalmost 8 years ago
and setting the Name as myapp-vpc instead of myapp-VPC
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
yeah i saw that, can i know why is it being converted to lowercase?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
i believe for consistency. is it a problem for you? (it does not convert tags)
rohit
rohitalmost 8 years ago
yeah i was wanting to keep whatever was defined in the name if possible
rohit
rohitalmost 8 years ago
Is there anything i could do to achieve this ?
rohit
rohitalmost 8 years ago(edited)
i mean i could do the same thing in my module but without converting the tags to lowercase
rohit
rohitalmost 8 years ago
locals {
  enabled    = "${var.enabled == "true" ? true : false }"
  id         = "${local.enabled == true ? join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes))) : ""}"
  name       = "${local.enabled == true ? format("%v", var.name) : ""}"
  namespace  = "${local.enabled == true ? format("%v", var.namespace) : ""}"
  stage      = "${local.enabled == true ? format("%v", var.stage) : ""}"
  attributes = "${local.enabled == true ? format("%v", join(var.delimiter, compact(var.attributes))) : ""}"

  # Merge input tags with our tags.
  # Note: `Name` has a special meaning in AWS and we need to disamgiuate it by using the computed `id`
  tags = "${
      merge( 
        map(
          "Name", "${local.id}",
          "Namespace", "${local.namespace}",
          "Stage", "${local.stage}"
        ), var.tags
      )
    }"
}
rohit
rohitalmost 8 years ago
Do you have plans to do the same in your module ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we use it in many other modules and we convert to lower case. actually, we always specify lower-case names. So for backwards compatibility we would not change it to not convert. But you might want to open a PR against our repo with added flag to specify whether to convert or not (e.g. var.convert_case) with default true
rohit
rohitalmost 8 years ago
i can definitely do that
rohit
rohitalmost 8 years ago
i don't think that would take a lot of effort
rohit
rohitalmost 8 years ago
i might be wrong
rohit
rohitalmost 8 years ago(edited)
i guess the tricky part would be to figure out nested conditional statements. I believe nested conditional statements will become easier in terraform v0.12
rohit
rohitalmost 8 years ago(edited)
i am not sure if this is a valid syntax in terraform
  id = "${local.enabled == true ? (local.convert_case == true ? lower(join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes)))) : join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes))))) : ""}"
rohit
rohitalmost 8 years ago
can anyone please confirm ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
more or less, but i would store the non-transformed value somewhere as a local
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
rather than duplicate it twice
rohit
rohitalmost 8 years ago
yeah that would make more sense
rohit
rohitalmost 8 years ago
how do i get access to push my git branch to your repository ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
oh, start by creating a github fork of the repo
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
then make your changes to the fork
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
from there, you can open up a PR against our upstream
rohit
rohitalmost 8 years ago(edited)
sorry, i thought that i can push my feature branch directly
rohit
rohitalmost 8 years ago
i opened a PR
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
can you paste the link
rohit
rohitalmost 8 years ago
PR link ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
reviewed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Also, can you add your business use-case to the “why” of the description
rohit
rohitalmost 8 years ago
i wanted to use convert_case variable but to make it match your variable naming convention i used convertcase but i took your suggestion and used i wanted to use convert_case variable but to make it match your variable naming convention i used convertcase`
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i think we use underscores everywhere
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
if we don’t it’s because the upstream resource did not (e.g. terraform)
rohit
rohitalmost 8 years ago
@Erik Osterman (Cloud Posse) thanks. Even though this was a small change it was fun working on it
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, this will make it easier for you to contribute other changes
rohit
rohitalmost 8 years ago
yea
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
thanks! we’ll get this merged tomorrow probably
rohit
rohitalmost 8 years ago
that would be great. when do you generally push to registry ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
oh, registry picks up changes in real-time
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so as soon as we merge and tag a release it will be there.
rohit
rohitalmost 8 years ago
that is awesome
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
since it’s late, it’s best to have andriy review too
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i miss things 😃
rohit
rohitalmost 8 years ago
no worries 🙂
rohit
rohitalmost 8 years ago
what tool do you use to automatically push to registry?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the registry actually is just a proxy for github
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
all we need to do is register a module with the registry
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
it’s not like docker registry where you have to push
rohit
rohitalmost 8 years ago
ohh i thought it was similar to docker registry
rohit
rohitalmost 8 years ago
but this is better i guess, this may have it's pros and cons
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i like that there’s zero overhead as a maintainer
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
nothing we need to remember to do
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
everytime i need to push a package to rubyforge i gotta dig up my notes
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i’m curious - is anyone else peeved by the TF_VAR_ prefix? I find us having to map a lot of envs. Plus, when using chamber they all get uppercased.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I want a simple cli that normalizes environment variables for terraform. it would work like the existing env cli, but support adding the TF_VAR_ prefix and auto-lower everything after it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
e.g.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
tfenv terraform plan
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
tfenv command
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this could be coupled with chamber.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
chamber exec foobar -- tfenv terraform plan
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
(not to be confused with the rbenv cli logic)
loren
lorenalmost 8 years ago
If case is the main complaint, I wonder if there's been any discussion in making the env case insensitive in terraform core?
loren
lorenalmost 8 years ago
I'm not turning up any discussion around it, but I'm on my phone and not searching all that extensively
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i know i’ve tested it for case insensitivity and it does not work
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so i have a prototype of the above that i’m about to push
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
it supports whitelists and blacklists (regex) for security (e.g. exclude AWS_* credentials)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this is going to make interoperability between all of our components much cleaner and our documentation easier to write.
loren
lorenalmost 8 years ago
Oh, I know it's case sensitive for sure, I mean something like a feature request to make it case insensitive so upper case works (which is more inline with env convention), without breaking backwards compatibility
antonbabenko
antonbabenkoalmost 8 years ago
Not related to the main discussion, but still :) consider using direnv tool to automatically set env per directory. I use it with terragrunt to set correctly IAM role to assume per directory.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, direnv is nice for that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
my problem is that we use kops, gomplate, chamber, etc
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
and the TF_VAR_ stuff makes it cumbersum
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
chamber upper cases everything
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
kops should not depend on TF_VAR_ envs
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so we end up duplicating a lot of envs (or reassigning them)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so i want a canonical list of normal envs that we can map to terraform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@antonbabenko though i’ve not gone deep on direnv
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
do you see a way to achieve the same thing in a DRY manner?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
if so, i’d prefer to use direnv
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
basically, i’d like to normalize envs (lowercase) and add TF_VAR_ prefix without defining by hand for each env
loren
lorenalmost 8 years ago
Do kops and chamber not namespace the envs they read?
loren
lorenalmost 8 years ago
If not, I suppose where I'm going is, why not use the TF_VAR_ env in those configs? All the prefixing would be annoying, but at least the values would only be defined once
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I don’t like making terraform the canonical source of truth
loren
lorenalmost 8 years ago
Oh chamber upper cases things. Blergh
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yea plus that
loren
lorenalmost 8 years ago
I guess I don't see how to inform the different utilities which envs to use or which env namespaces/prefixes to apply per utility... I think it would require going down the road you started with a new wrapper utility with it's own config file
antonbabenko
antonbabenkoalmost 8 years ago
I once used a shell script which converted env vars for similar reason, but it was before I discovered direnv.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I think I am going to combine what I have with direnv
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Per your tip :-)
loren
lorenalmost 8 years ago
Yeah, sometimes a little copy-paste is still the simplest abstraction...
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@tamsky are you also using direnv?
Jan
Janalmost 8 years ago
The problem I found with using direnv previously on a large project was that users of the project started to expect a .envrc file anytime any thing could or needed to be set in env vars. Maybe worth thinking about if there is a clear cut separation between what IS in direnv and what is NOT
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Jan true - and to your point that you raised earlier with me about having a clear cut delineation of what goes where
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i don’t have a “best practice” in mind yet. i need to let this simmer for a bit.
Jan
Janalmost 8 years ago
consistency is better than correctness 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
indeed.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Jan going to move to #geodesic
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) Did you get a chance to review my PR ?
rohit
rohitalmost 8 years ago
Is it possible to attach ASG to existing cloudwatch event using terraform ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yes, that’s possible
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
are you using our autoscale group module?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Jake Lundberg (Coder) it was just brought to our attention that the registry is mangling html entites: https://registry.terraform.io/modules/cloudposse/ansible/null/0.4.1
erik
erikalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
while on github we see
erik
erikalmost 8 years ago
Jake Lundberg (HashiCorp)
Jake Lundberg (HashiCorp)almost 8 years ago
OK, I’d open an issue in Github.
rohit
rohitalmost 8 years ago
@Erik Osterman (Cloud Posse) i am using aws_autoscaling_group resource, so once an ASG is created i want to go and add the ASG name in cloudwatch event so that it will disassociate nodes from chef server
rohit
rohitalmost 8 years ago
makes sense ?
joshmyers
joshmyersalmost 8 years ago
@rohit I'm not sure on the question there
joshmyers
joshmyersalmost 8 years ago
I've seen those disassociation scripts put in as shutdown scripts
joshmyers
joshmyersalmost 8 years ago
Although that does need a clean shutdown event
rohit
rohitalmost 8 years ago
Let me explain this in a better way. When autoscaling event is triggered, the userdata script gets executed and it does associate the node with the chef server. When a node in this ASG is terminated, a cloudwatch event is triggered which inturn calls a lambda function to disassociate the node from the chef server
rohit
rohitalmost 8 years ago
i was planning to do this in terraform
rohit
rohitalmost 8 years ago
so i am using aws_autoscaling_group resource to create ASG
joshmyers
joshmyersalmost 8 years ago
OK, still not sure what the question is :D
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit as @Erik Osterman (Cloud Posse) pointed out, you can connect the ASG to CloudWatch alarms using Terraform https://github.com/cloudposse/terraform-aws-ec2-autoscale-group/blob/master/autoscaling.tf#L27
rohit
rohitalmost 8 years ago
i want to connect the ASG to cloudwatch event rule
rohit
rohitalmost 8 years ago
{

  "source": [
    "aws.autoscaling"
  ],
  "detail-type": [
    "EC2 Instance Terminate Successful"
  ],
  "detail": {
    "AutoScalingGroupName": [
      "MY-ASG"
    ]
  }
}
joshmyers
joshmyersalmost 8 years ago(edited)
Looks like you are on the right track for that. I'm still not seeing a question or explanation of what problem you are having. Have you looked at what @Andriy Knysh (Cloud Posse) posted?
rohit
rohitalmost 8 years ago
I think what i need is aws_cloudwatch_event_rule and not aws_cloudwatch_metric_alarm
rohit
rohitalmost 8 years ago
i am struggling to figure out how to add my asg name to cloudwatch event rule
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
resource "aws_cloudwatch_event_rule" "console" {
  name        = "name"
  description = "....."

  event_pattern = <<PATTERN
{
  "detail-type": [
    "..."
  ]
 ,
 "resources": [
   "${aws_autoscaling_group.default.name}"
]
}
PATTERN
}
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
try this ^
rohit
rohitalmost 8 years ago(edited)
rohit
rohitalmost 8 years ago
Step 7: Add a CloudWatch rule to trigger the Lambda function on instance termination
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
rohit
rohitalmost 8 years ago
will do. Thanks
rohit
rohitalmost 8 years ago
i am really struggling with this today
rohit
rohitalmost 8 years ago
this is helpful
joshmyers
joshmyersalmost 8 years ago
You don't want "${join("\",\"", var.autoscaling_group_names)}" though, right
rohit
rohitalmost 8 years ago
I think i will still have to add my ASG name to the cloudwatch event
rohit
rohitalmost 8 years ago(edited)
i am not thinking straight today
rohit
rohitalmost 8 years ago
so pardon me
joshmyers
joshmyersalmost 8 years ago
Yup, you should do that
pablo
pabloalmost 8 years ago
has anyone used the resource aws_mq_broker https://www.terraform.io/docs/providers/aws/r/mq_broker.html in conjunction Hashicorp vault to store the users as a list?
pablo
pabloalmost 8 years ago(edited)
I have tried to use them together to display a list a users from Vault but I think the Terraform resource checks for its dependancies before anything is ran against the API
pablo
pabloalmost 8 years ago(edited)
I have tried the following:

Serving Individual users with attributes
user                = [
  {
      username       = "${data.vault_generic_secret.amq.data["username"]}"
      password       = "${data.vault_generic_secret.amq.data["password"]}"
      console_access = true
  }
]
pablo
pabloalmost 8 years ago(edited)
&

Sending a dictionary of users
user = [${data.vault_generic_secret.amq.data["users"]}]
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
what's the problem you're having?
pablo
pabloalmost 8 years ago
the issue is that in order to use this resources you would have to keep user login information in version control
pablo
pabloalmost 8 years ago
what I want to do is keep the user information in Vault separate of the source code
pablo
pabloalmost 8 years ago
is this possible
pablo
pabloalmost 8 years ago
I am currently having to manually replace the user credentials with REDACTED with every change to Terraform
pablo
pabloalmost 8 years ago
I hope I am explaining my issue accurately
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i am a confused because from the example, it looks like to me they are omnig from vault?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

      username       = "${data.vault_generic_secret.amq.data["username"]}"
      password       = "${data.vault_generic_secret.amq.data["password"]}"
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
and not form source control
pablo
pabloalmost 8 years ago
those are my examples of what I have tried (or close to that)
pablo
pabloalmost 8 years ago
but they don not work
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
aha, i see
pablo
pabloalmost 8 years ago
it fails before it makes an API call
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ok, so what you're trying to do looks good more or less. now we need to figure out why it's failing.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
can you share the invocation of vault_generic_secret?
pablo
pabloalmost 8 years ago
which leads me to believe that it does some sort of dependency check for required attributes
pablo
pabloalmost 8 years ago
well I have gone as far as checking to make sure Terraform is getting the secret which it is
pablo
pabloalmost 8 years ago
but Terraform fails even before it queries Vault
pablo
pabloalmost 8 years ago
I have verified this by outputting the invocation of the secret. Which works when I do not use the AMQ Resource but does not when I include the AMQ resource in the Terraform config
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
can you share the precise error?
pablo
pabloalmost 8 years ago
lemme see if I can create a quick mock
pablo
pabloalmost 8 years ago
I thought I saved my work in a branch but didn’t 🤦
pablo
pabloalmost 8 years ago
ok here is the error with some trace
pablo
pabloalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ok, please share the invocation of module.amq
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
and the invocation of data.vault_generic_secret
pablo
pabloalmost 8 years ago
sorry but what do you mean by invocation? do you want to see how I am executing it our do you want the entire stack trace?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
oh, yes, that's ambiguous
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i mean the HCL code
pablo
pabloalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I don't see data.vault_generic_secret
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
and I don't see module.amq
pablo
pabloalmost 8 years ago
wasn’t done, I keep getting distracted 😕
pablo
pabloalmost 8 years ago
pablo
pabloalmost 8 years ago
this one is the root config and the former was the module I created
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ok
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I would explore the data structures.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Error: module.amq.aws_mq_broker.amq_broker: "user.0.password": required field is not set
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this gives me a hint that perhaps the input data structure is wrong
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
perhaps ${data.vault_generic_secret.amq.data["users"]} is not in the right structure.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
is users a list of maps?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

[{ username: "foo", password: "bar"}, {username: "a", password: "b"}]
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
also, I have seen problem with this
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

amq_users = ["${data.vault_generic_secret.amq.data["users"]}"]
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
where in ["${...}"] the content of the ${...} interpolation returns a list.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so we get a list of lists.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
terraform is supposed to flatten this, however, I have found this not the case when working with various providers.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
my guess is that the authors don't properly handle the inputs.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
perhaps try this too
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

amq_users = "${data.vault_generic_secret.amq.data["users"]}"
pablo
pabloalmost 8 years ago
thanks I’ll give that a shot
pablo
pabloalmost 8 years ago
do you know if Terraform first tries to validate the resource dependancies before actually executing the resource? During the plan or pre-apply stages?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

validate the resource dependancies
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
not from what i've seen. there's very little "schema" style validation
rohit
rohitalmost 8 years ago
I noticed that my change for convert_case to terraform-terraform-label defaults the value "true" but in main.tf i am using it as boolean
rohit
rohitalmost 8 years ago
so i am going to submit another PR to fix this issue
rohit
rohitalmost 8 years ago
sorry about that
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit wait 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
everything is ok
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you convert it to boolean in the locals
rohit
rohitalmost 8 years ago
i feel something is wrong
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and you need to add it 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
sorry, we missed it
rohit
rohitalmost 8 years ago
instead of using var.convert_case i used local.convert_case
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
locals {
  convert_case = "${var.convert_case == "true" ? true : false }"
 }
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
add this ^
rohit
rohitalmost 8 years ago
yeah that's what i am doing now
rohit
rohitalmost 8 years ago
i found this when i was trying to use it in my project 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and use one locals, no need to make multiple
rohit
rohitalmost 8 years ago
will do
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) i am sorry about not noticing that earlier
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yea, we did not notice it either 🙂
rohit
rohitalmost 8 years ago
submitted another PR
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
tested this time? 🙂
rohit
rohitalmost 8 years ago
what is the recommended way to test it ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
Looks good to me
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
didn't realize that formatting would cause The Travis CI build to fail
rohit
rohitalmost 8 years ago
pushed the change
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
thanks, merged
rohit
rohitalmost 8 years ago
awesome
rohit
rohitalmost 8 years ago
which tool do you use for secrets management ?
davidvasandani
davidvasandanialmost 8 years ago
my 2¢, I love credstash works really well with Terraform.
davidvasandani
davidvasandanialmost 8 years ago
if you can use KMS in AWS
rohit
rohitalmost 8 years ago
is there an API for credstash ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
any thoughts about using hashicorp vault ?
davidvasandani
davidvasandanialmost 8 years ago
Valut is really cool but is a higher barrier to start using (setting up servers) vs credstash is serverless.
rohit
rohitalmost 8 years ago
that is great
rohit
rohitalmost 8 years ago
what about chamber ?
davidvasandani
davidvasandanialmost 8 years ago
chamber uses AWS Systems Manager Parameter Store also serverless.
davidvasandani
davidvasandanialmost 8 years ago(edited)
I’m reading https://segment.com/blog/the-right-way-to-manage-secrets/ and probably would have picked chamber if it was available when I started using credstash
rohit
rohitalmost 8 years ago
good to know. will read about it
rohit
rohitalmost 8 years ago
I am looking for something that will play nicely with Chef
Andrew Jeffree
Andrew Jeffreealmost 8 years ago
I'm looking at implementing vault at my work but that's to cover multiple requirements not just terraform secrets.
rohit
rohitalmost 8 years ago
i am looking at something that is not limited to terraform secrets as well
rohit
rohitalmost 8 years ago
but something that works with AWS + Chef
davidvasandani
davidvasandanialmost 8 years ago
I use credstash for .env in our rails app, terraform secrets, and secrets in Salt. Having said that after reading more about chamber I probably would have gone with that instead.
btai
btaialmost 8 years ago(edited)
anyone here use terraform to spin up EKS/AKS/GKE and use the kubernetes/helm providers
Matthew
Matthewalmost 8 years ago
Yes I spin up EKS and Helm as well as Concourse using Terraform @btai
btai
btaialmost 8 years ago
@Matthew do you have RBAC enabled? if so, when you spin up your EKS cluster are you automatically running a helm install in the same terraform apply?
Matthew
Matthewalmost 8 years ago
Yes to both of those
btai
btaialmost 8 years ago
scenario being, running a helm install to provision the cluster with roles, role bindings, cluster role bindings, possibly cluster wide services, etc.
btai
btaialmost 8 years ago
so im not using EKS, im using AKS so im not sure if you run into this issue
btai
btaialmost 8 years ago
but im attempting to create some very basic clusterrolebindings
btai
btaialmost 8 years ago
provider "kubernetes" {
  host                   = "${module.aks_cluster.host}"
  client_certificate     = "${base64decode(module.aks_cluster.client_cert)}"
  client_key             = "${base64decode(module.aks_cluster.client_key)}"
  cluster_ca_certificate = "${base64decode(module.aks_cluster.ca_cert)}"
}
Matthew
Matthewalmost 8 years ago
Give me a moment and we can discuss
btai
btaialmost 8 years ago
kk
Gabe
Gabealmost 8 years ago
anyone here have experience with terraform enterprise? is it worth the cost in your opinion?
btai
btaialmost 8 years ago
i didnt do too much digging, but i wasnt a fan of having to have a git repo per module. they do this because they use git tags for versioning modules, but i didnt want to have that many repos
Dan
Danalmost 8 years ago
i have no clue why this wont work
Dan
Danalmost 8 years ago
davidvasandani
davidvasandanialmost 8 years ago(edited)
-> this should fix it owners = ["137112412989"]

also you can simplify your filters 👇️🏻

  filter {
    name   = "name"
    values = ["amzn-ami-hvm-*-x86_64-gp2"]
  }
davidvasandani
davidvasandanialmost 8 years ago(edited)

# Grab most recent linux ami
data "aws_ami" "linux_ami" {
  most_recent      = true
  owners = ["137112412989"]
  executable_users = ["self"]

   filter {
    name   = "name"
    values = ["amzn-ami-hvm-*-x86_64-gp2"]
  }
}


also I’m not sure if values = ["amzn-ami-hvm-*"] is enough so I’ve updated it to values = ["amzn-ami-hvm-*-x86_64-gp2"]
davidvasandani
davidvasandanialmost 8 years ago
cc @Dan ☝️🏻
Dan
Danalmost 8 years ago
Thank you so much!!
Dan
Danalmost 8 years ago
Seems like owners is the key component
Steven
Stevenalmost 8 years ago
@Dan Always use owner for Amazon AMIs. Otherwise you could get anyone's AMI with a similar name. And there are many of those. Same thing for other vendor AMIs. Here is a terraform module that handles a number of vendors https://github.com/devops-workflow/terraform-aws-ami-ids
Dan
Danalmost 8 years ago
Thank you!!!
inactive
inactivealmost 8 years ago
hello! i have a problem with terraform and cloudfront, wondering if someone has seen this issue
inactive
inactivealmost 8 years ago
I have a website hosted statically on S3 with Private ACL. I am using Cloudfront to serve the content
inactive
inactivealmost 8 years ago(edited)
I am using an S3 origin identity, which requires an access identity resource
inactive
inactivealmost 8 years ago
and I see that it creates the access identity successfully, but the problem is that it does not attach it to the cloudfront distro
inactive
inactivealmost 8 years ago
when I go back to the AWS console, the access id is listed in the dropdown but not selected
inactive
inactivealmost 8 years ago(edited)
i suspect the problem has to do with this section of the code:
inactive
inactivealmost 8 years ago
any tips?
inactive
inactivealmost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@inactive here is what we have and it’s working, take a look https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf
inactive
inactivealmost 8 years ago
mmm… you have the same code as i do. the s3_origin_config snippet references the access_id, which I expected would set it
inactive
inactivealmost 8 years ago
not sure why its not doing in my case
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you can share your complete code, we’ll take a look (maybe something else is missing)
inactive
inactivealmost 8 years ago
ok
inactive
inactivealmost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@inactive try deleting this
  website {
    index_document = "${var.webui_root_object}"
  }
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it prob creates the bucket as website (need to verify if that statement is enough for that), but anyway, if it creates a website, it does not use origin access identity - cloudfront distribution just points to the public website URL
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we also have this module to create CloudFront distribution for a website (which could be an S3 bucket or a custom origin) https://github.com/cloudposse/terraform-aws-cloudfront-cdn
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and here is how to create a website from S3 bucket https://github.com/cloudposse/terraform-aws-s3-website
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
in short, CloudFront could be pointed to an S3 bucket as origin (in which case you need origin access identity) AND also to an S3 bucket as a website - they have completely diff URLs in these two cases
inactive
inactivealmost 8 years ago
ok let me try that
Dan
Danalmost 8 years ago
i get this error Resource 'aws_security_group.dbsg' not found for variable 'aws_security_group.dbsg.id' even tho i created the sg... hmmm
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@Dan need help or found the solution?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@inactive how it goes?
Dan
Danalmost 8 years ago
i found a new solution! thank you tho!
Dan
Danalmost 8 years ago
i think i did a local and an outpiut
Dan
Danalmost 8 years ago
to make it work
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Dan
Danalmost 8 years ago
my favorite is the first word in the first sentence
Dan
Danalmost 8 years ago
Terrafom is an amazing tool that lets you define your infrastructure as code. Under the hood it's an incredibly powerful state machine that makes API requests and marshals resources.
Dan
Danalmost 8 years ago
ill have to watch this
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Our terraform-aws-cloudtrail does not current have any code for that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this module created by Jamie does something similar
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
with SNS alarms
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I have not personally deployed it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@davidvasandani someone else reported the exact same EKS problem you ran into
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@patrickleet is trying it right now
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
maybe you can compare notes
patrickleet
patrickleetalmost 8 years ago
@patrickleet has joined the channel
davidvasandani
davidvasandanialmost 8 years ago
Good to know I’m not alone.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
or let him know what you tried
davidvasandani
davidvasandanialmost 8 years ago(edited)
Lets see if I kept my notes after moving to kops 😂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
kops is pretty easy/peasy right?
davidvasandani
davidvasandanialmost 8 years ago
So easy.
davidvasandani
davidvasandanialmost 8 years ago(edited)
I was up and running in no time and have started learning to deploy statup.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
nice! let me know if you get stuck - i can unblock you
patrickleet
patrickleetalmost 8 years ago
haha ok so you moved to kops
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
kops is much easier to manage the full SDLC of a kubernetes cluster
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
rolling updates, drain+cordon
patrickleet
patrickleetalmost 8 years ago
yea I have a couple of kops clusters
patrickleet
patrickleetalmost 8 years ago
and a gke one
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ok, yea, so you know the lay of the land
patrickleet
patrickleetalmost 8 years ago
I was specifically trying to play with eks using terraform and came across your modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we rolled out EKS ~2 months ago for the same reason
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
these modules were the byproduct of that. @Andriy Knysh (Cloud Posse) is not sure what changed. we always leave things in a working state.
patrickleet
patrickleetalmost 8 years ago
yea - I'm able to plan the vpc
patrickleet
patrickleetalmost 8 years ago
which has tags calculated
patrickleet
patrickleetalmost 8 years ago
which is where it's choking
patrickleet
patrickleetalmost 8 years ago
it's not able to get the count
davidvasandani
davidvasandanialmost 8 years ago
Same here.
patrickleet
patrickleetalmost 8 years ago
haven't actually tried applying the vpc plan and moving further though
davidvasandani
davidvasandanialmost 8 years ago
@patrickleet I think we ran into the same issue.
davidvasandani
davidvasandanialmost 8 years ago
Wait.
davidvasandani
davidvasandanialmost 8 years ago
I was able to plan the VPC just fine.
davidvasandani
davidvasandanialmost 8 years ago
make your enabled var false
davidvasandani
davidvasandanialmost 8 years ago
it will plan the VPC with the tags count just fine.
davidvasandani
davidvasandanialmost 8 years ago
but then errors out when I set it to true, see the Slack link above.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
I’ll take a look at the EKS module tomorrow. Not good to have it in that state :(
rohit
rohitalmost 8 years ago(edited)
Is there a comprehensive gitignore file for any terraform project ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
that's what i was using
rohit
rohitalmost 8 years ago
do you generally state the plan files somewhere if not in your repo ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you mean to add the plan files to .gitignore?
rohit
rohitalmost 8 years ago(edited)
i mean do you store the generated plan somewhere
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
if you do it on your local computer, the state is stored locally. We use S3 state backend with DynamoDB table for state locking, which is a recommended way of doing things https://github.com/cloudposse/terraform-aws-tfstate-backend
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
are you asking about the TF state or about the files that terraform plan can generate and then use for terraform apply?
rohit
rohitalmost 8 years ago
i was asking about the later. when you run terraform plan --var-file="config/app.tfvars" --out=app.storage.plan and then terraform apply app.storage.plan
rohit
rohitalmost 8 years ago
do you store the generated plan file somewhere or just ignore it ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
since we store TF state in S3, we don’t use the plan files, you can say we ignore them
rohit
rohitalmost 8 years ago
cool
rohit
rohitalmost 8 years ago
if i have tfvars inside a config dir, ex: config/app1.tfvars, config/app2.tfvars, i think including *.tfvars in gitignore will restrict both these files to be checkedin in my code repo, correct ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
maybe **/*.tfvars?
rohit
rohitalmost 8 years ago
i thought *.tfvars would be enough, maybe i was wrong
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
should be enough
rohit
rohitalmost 8 years ago
will try that
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
in this case it’s not actually needed. but if you use https://github.com/cloudposse/terraform-aws-dynamodb-autoscaler, then it will help to prevent TF from recreating everything when the auto-scaler changes the read/write capacity
Jan
Janalmost 8 years ago
Life cycle hooks can also be super useful for doing X when Y happens. A common case I have is when destroying a Cassandra cluster I need to unmount the ebs volumes from the instances so I can do a fast snapshot and then terminate
Jan
Janalmost 8 years ago
On Event terminate remote-exec umount
Jan
Janalmost 8 years ago
Also great for zero downtime changes, create before destroy
Jan
Janalmost 8 years ago
Etc
Jan
Janalmost 8 years ago
In the case you posted I would expect its to let terraform know that it doesn't need to care about any. Changes of the values
Jan
Janalmost 8 years ago
lifecycle {
ignore_changes = ["read_capacity", "write_capacity"]
}
rohit
rohitalmost 8 years ago
makes sense
rohit
rohitalmost 8 years ago
never use lifecycle hooks so it is new to me
rohit
rohitalmost 8 years ago
In general, where are the lifecycle hooks used ?
joshmyers
joshmyersalmost 8 years ago
Can be used under different conditions. A common one could be where Terraform isn’t the only thing managing a resource, or element of resources.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
or if a resource could change outside of TF state like in the example with DynamoDB auto-scaler, which can update the provisioned capacity and TF would see different values and try to recreate it
inactive
inactivealmost 8 years ago
@Andriy Knysh (Cloud Posse) I am happy to report that your suggestion fixed my problem, re: CloudFront
inactive
inactivealmost 8 years ago
I still don’t quite understand how it’s still able to pull the default html page, since I thought that I had to explicitly define it under the index_document parameter
inactive
inactivealmost 8 years ago
but it somehow works
inactive
inactivealmost 8 years ago
tyvm for your help
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
glad it worked for you @inactive
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
did you deploy the S3 bucket as a website?
inactive
inactivealmost 8 years ago
i assume no, since I removed the whole website {…} section
inactive
inactivealmost 8 years ago
but CF doesn’t seem to care, as it serves the content without that designation
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
which fixes value of 'count' cannot be computed errors
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@davidvasandani @patrickleet
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
☝️
davidvasandani
davidvasandanialmost 8 years ago
Thanks @Andriy Knysh (Cloud Posse) and @Erik Osterman (Cloud Posse)
davidvasandani
davidvasandanialmost 8 years ago
While this module works y’all still prefer kops though right?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yea...
davidvasandani
davidvasandanialmost 8 years ago(edited)
This is more a proof of concept or looking for folks to ask/add additional features?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
It lacks a story for managing rolling upgrades
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Since we don’t have a story for that, we aren’t pushing it. It’s mostly there on standby pending customer request to use EKS over Kops
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Then we will invest in the upgrade story.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I really like the architecture of the modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
And the way we decomposed it makes it easy to have different kinds of node pools
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
The upgrade story would probably use that story to spin up multiple node pools and move workloads around and then then scale down the old node pool
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Almost like replicating the Kubernetes strategy for deployments and replica sets
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
But for auto scale groups instead
sohel2020
sohel2020almost 8 years ago
sohel2020
sohel2020almost 8 years ago
it sets a router53 record for me but it's not working
sohel2020
sohel2020almost 8 years ago(edited)
dig <http://production-kibana.infra.mytonic.com|production-kibana.infra.mytonic.com>                                                                              

;; QUESTION SECTION:
;production-kibana.infra.mytonic.com. IN	A

;; ANSWER SECTION:
<http://production-kibana.infra.mytost.com|production-kibana.infra.mytost.com>. 59	IN CNAME <http://vpc-fluentd-production-elastic-43nbkjmxhatoajegdhyxekul3a.ap-southeast-1.es.amazonaws.com/_plugin/kibana/|vpc-fluentd-production-elastic-43nbkjmxhatoajegdhyxekul3a.ap-southeast-1.es.amazonaws.com/_plugin/kibana/>.

;; AUTHORITY SECTION:
.			86398	IN	SOA	<http://a.root-servers.net|a.root-servers.net>. <http://nstld.verisign-grs.com|nstld.verisign-grs.com>. 2018120700 1800 900 604800 86400

;; Query time: 333 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
sohel2020
sohel2020almost 8 years ago(edited)
but if I hit <http://production-kibana.infra.mytost.com> it's not working.
sohel2020
sohel2020almost 8 years ago
I have to add <http://production-kibana.infra.mytost.com/_plugin/kibana/> manually
sohel2020
sohel2020almost 8 years ago
@Andriy Knysh (Cloud Posse)
Jan
Janalmost 8 years ago
I have a generalish terraform / geodesic question so not sure if I should ask in here or #geodesic
Jan
Janalmost 8 years ago
I'd like to spin up . 4 accounts with 4 identical vpc's (with the exception of name and cidr) in which 3 will have kops managed k8s clusters
Jan
Janalmost 8 years ago
2 of those 3 the k8s cluster would be launched after the vpc needs to be around for some time
Jan
Janalmost 8 years ago
What I have not quite yet under stood is how the two different flows will look.

1.a) create vpc b) create resources in that vpc c) create k8s cluster with kops in existing vpc
2.a) create vpc using kops b) create resources in the vpc created by kops
Jan
Janalmost 8 years ago
for flow 1 in a geodesig way
Jan
Janalmost 8 years ago
im not sure I understand how or if it is supported to launch into and EXISTING vpc
Jan
Janalmost 8 years ago
terraform-aws-kops-vpc-peering - Terraform module to create a peering connection between a backing services VPC and a VPC created by Kops
Jan
Janalmost 8 years ago
So is it expected that any geodesic kops created k8s cluster will run in its own vpc?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@Jan i’ll help you
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so yes, you can deploy kops cluster into an existing VPC
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
but we don’t do that for a few reason
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you don’t want to manage CIDR overlaps for example
Jan
Janalmost 8 years ago
I know I can and how to, its the pattern I have followed
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so we deploy kops into a separate VPC
Jan
Janalmost 8 years ago
mmm
Jan
Janalmost 8 years ago
Not sure I understand the rational there
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and then deploy a backing-services VPC for all other stuff like Aurora, Elasticsearch, Redis etc.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
then we do VPC peering
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we don’t want to manage CIDR overlaps
Jan
Janalmost 8 years ago
there is no overlap
Jan
Janalmost 8 years ago
the k8s cluster uses the vpc cidr
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
but you can deploy kops into an existing VPC
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
there is no diff, but just more separation
Jan
Janalmost 8 years ago
IP's are still managed by the dhcp optionset in the vpc
Jan
Janalmost 8 years ago
mmm
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and we have TF modules that do it already
Jan
Janalmost 8 years ago
interesting
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
i can show you the complete flow for that (just deployed it for a client)
Jan
Janalmost 8 years ago
Alright I think I will write a TF module to do k8s via kops into an existing and make a pr
Jan
Janalmost 8 years ago
Yea I have seen the flow for creating a backing VPC + kops (k8s)vpc with peering
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
when we tried to deploy kops into existing VPC, we ran into a few issues, but i don’t remember exactly which ones
Jan
Janalmost 8 years ago
I recall there being weirdness and cidr overlaps if you dont use the subnet =ids and stuff
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
deploying into a separate VPC, did not see any issues
Jan
Janalmost 8 years ago
so for example I have some thing like this
Jan
Janalmost 8 years ago
corporate network === AWS DirectConnect ==> [shared service-vpc(k8s)] /22 cidr ---> peering --> [{prod,pre-prod}-vpc(k8s)] /16 cidr
Jan
Janalmost 8 years ago
where we run shared monitoring and logging and ci/cd services in the shared-services vpc (mostly inside k8s)
Jan
Janalmost 8 years ago
k8s also has ingress rules that expose services in the peered prod and pre prod accounts tot he corp network
Jan
Janalmost 8 years ago
overhead on the corp network is just the routing of the /22
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so you already using vpc peering?
Jan
Janalmost 8 years ago
I am busy setting this all up
Jan
Janalmost 8 years ago
corp network will have direct connect to a /22 vpc
Jan
Janalmost 8 years ago
the /22 with have peering to many vpcs within a /16
Jan
Janalmost 8 years ago
that /16 we will split as many times as we need, probably into /24's
Jan
Janalmost 8 years ago
or 23's
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@Jan your question was how to deploy kops into an existing VPC?
Jan
Janalmost 8 years ago
My question was more if there is geodesic support for that flow or if i should add a module to do so
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we deploy kops (from geodesic, but it’s not related) from a template, which is here https://github.com/cloudposse/geodesic/blob/master/rootfs/templates/kops/default.yaml
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the template deploys it into a separate vpc
Jan
Janalmost 8 years ago
Yep this I used to do having terraform render a go templated
Jan
Janalmost 8 years ago
ok I will play with a module and see where the overlap/handover is
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
if we want to deploy into an existing vpc using the template, it should be modified
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
there is no TF module for that
Jan
Janalmost 8 years ago
Yep, I will create one
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
TF module comes into play when we need to do vpc peering
Jan
Janalmost 8 years ago
just figured Id ask before I made one
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
you thinking about a TF module to deploy kops?
Jan
Janalmost 8 years ago
a new tf module to fetch vpc metadatas (maybe), and deploy k8s via kops into the existing vpc
Jan
Janalmost 8 years ago
vpc metadata would not be needed if it vpc was created in tf
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Jan
Janalmost 8 years ago(edited)
yea so this is that flow in reverse
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@Jan not sure if it answers your questions 😞 but what we have is 1) kops template to deploy kops into a separate VPC; 2) TF modules for VPC peering and kops metadata lookup
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
we played with deploying kops into an existing vpc, but abandoned it for a few reasons
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@sohel2020 you have to manually add _plugin/kibana/ to <http://production-kibana.infra.mytost.com> because URL paths are not supported for CNAMEs (and <http://production-kibana.infra.mytost.com|production-kibana.infra.mytost.com> is a CNAME to the Elasticsearch URL generated by AWS)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
even if you do it in the Route53 console, you get the error
The record set could not be saved because:
- The Value field contains invalid characters or is in an invalid format.
Jan
Janalmost 8 years ago
Its all good bro, thanks. I will make a module to support my use case
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yea you want to inject kops into a vpc. We don’t have that but I do like it and we have a customer that did that but without modularizing it.
Jan
Janalmost 8 years ago
I have done it in several ways in tf
Jan
Janalmost 8 years ago
I will look to make a module and contribute it
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We would like to have a module for it, so that would be awesome
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
thanks @Jan
Ryan Ryke
Ryan Rykealmost 8 years ago(edited)
just a quick sanity check. when was the last time someone used the terraform-aws-vpc module... i copy pasta'd the example
module "vpc" {
  source    = "git::<https://github.com/cloudposse/terraform-aws-vpc.git?ref=master>"
  namespace = "cp"
  stage     = "prod"
  name      = "app"
}

and it gave me Error: module "vpc": missing required argument "vpc_id"
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We use it all the time
Ryan Ryke
Ryan Rykealmost 8 years ago
sorta funny when thats what im trying to create
Ryan Ryke
Ryan Rykealmost 8 years ago
perhaps the sample is messed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Last week most recently. @Andriy Knysh (Cloud Posse) any ideas?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Most current examples are in our root modules folder
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Sec
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@solairerove will be adding and testing all examples starting next week probably
solairerove
solairerovealmost 8 years ago
@solairerove has joined the channel
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
just used it yesterday on the EKS modules
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
used the example that pulled the master branch
Ryan Ryke
Ryan Rykealmost 8 years ago
maybe im an idiot
Ryan Ryke
Ryan Rykealmost 8 years ago
let me go back and check
Ryan Ryke
Ryan Rykealmost 8 years ago
nm nothing to see here
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Ryan Ryke
Ryan Rykealmost 8 years ago
i musta gotten my pasta messed up
Ryan Ryke
Ryan Rykealmost 8 years ago
confirmed <- idiot
Ryan Ryke
Ryan Rykealmost 8 years ago
at least it didnt take me all day
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
😁
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the error must have been from another module?
Ryan Ryke
Ryan Rykealmost 8 years ago
yeah
Ryan Ryke
Ryan Rykealmost 8 years ago
Ryan Ryke
Ryan Rykealmost 8 years ago
whats kinesis in there for.
Ryan Ryke
Ryan Rykealmost 8 years ago
shipping somewhere is suppose
joshmyers
joshmyersalmost 8 years ago
Could have lambda slurp off the Kinesis stream, for example
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
This module was done more for checking a compliance checkbox
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
All logs stored in s3, but nothing immediately actionable
Ryan Ryke
Ryan Rykealmost 8 years ago
ahh cool. they have shipping to cwl now, was just wondering if there was a specific purpose
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Yea, unfortunately not.
rohit
rohitalmost 8 years ago
how to know the best value for max_item_size for memcache aws_elasticache_parameter_group ?
rohit
rohitalmost 8 years ago
does it depend on the instance type ?
joshmyers
joshmyersalmost 8 years ago
@rohit Are you hitting a problem caused by the default max item size?
rohit
rohitalmost 8 years ago
@joshmyers no. i just want to know how the max_item_size works
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Max item size is the length of the longest value stored. If you are serializing data structures or session data, this could get quite large. If you are just storing simple key value pairs a smaller number is probably fine. This is a hint to memcache for how to organize the data and the size of slabs for storing objects.
joshmyers
joshmyersalmost 8 years ago
What kinda things are you storing in there?
rohit
rohitalmost 8 years ago
we are using memcache for tomcat session storage
rohit
rohitalmost 8 years ago
so basically session information
joshmyers
joshmyersalmost 8 years ago
Is 1mb object storage enough for you?
rohit
rohitalmost 8 years ago
I think so but i will have to check
rohit
rohitalmost 8 years ago
Looks like availability_zones option is deprecated in favor of preferred_availability_zones
https://github.com/cloudposse/terraform-aws-elasticache-memcached/blob/65a0655e8bde7fb177516bbcdd394eddc8cfcc88/main.tf#L76
rohit
rohitalmost 8 years ago
Is there a way to view what is stored in dynamodb table ? I was not able to find anything but empty table
Steven
Stevenalmost 8 years ago
The Dynamodb table can be viewed and modified via the DynamoDB UI. There is nothing hiding it
Once a Terraform config is setup correctly to write to S3 with locking and applied successfully, it will write to that table. Utill then it will be empty
rohit
rohitalmost 8 years ago
ohh ok
rohit
rohitalmost 8 years ago
I am using the terraform-aws-vpc module https://github.com/terraform-aws-modules/terraform-aws-vpc
rohit
rohitalmost 8 years ago
is it possible to update openvpn configuration,after a vpc is created using this module ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
openvpn? <-- not related to vpc
rohit
rohitalmost 8 years ago
Is there a way to provide subnet information instead of cidr_blocks in resource aws_security_group ingress and egress ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Can you share an example? Pseudo code
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I am on my phone
Steven
Stevenalmost 8 years ago
But it is not hard to use data to look up the cidr blocks
rohit
rohitalmost 8 years ago(edited)
@Erik Osterman (Cloud Posse) i am using cloudposse/terraform-aws-efs module https://github.com/cloudposse/terraform-aws-efs/blob/1ad219e482eba444eb31b6091ecb6827a0395644/main.tf#L38
rohit
rohitalmost 8 years ago
and i have to pass security_groups
rohit
rohitalmost 8 years ago
when i execute the following code
rohit
rohitalmost 8 years ago
rohit
rohitalmost 8 years ago
i get the following error
rohit
rohitalmost 8 years ago
rohit
rohitalmost 8 years ago
any ideas why ?
Jan
Janalmost 8 years ago
mmm
joshmyers
joshmyersalmost 8 years ago
@rohit does it work without the aws_efs_mount_target resource? Does it create the security group?
joshmyers
joshmyersalmost 8 years ago
It looks legit on first inspection (under caffeinated at the mo)
Jan
Janalmost 8 years ago
yea I would agree, nothing jumps out as being wrong
joshmyers
joshmyersalmost 8 years ago
joshmyers
joshmyersalmost 8 years ago
Also, you shouldn’t need that explicit depends_on, unless that was you testing the graph
rohit
rohitalmost 8 years ago
i thought it was dependency error so added depends_on
rohit
rohitalmost 8 years ago
without aws_efs_mount_target, i get the following error
* module.storage.module.kitemedia.aws_security_group.media: "ingress.0.cidr_blocks.0" must contain a valid CIDR, got error parsing: invalid CIDR address: subnet-012345d8ce0d89dbc
joshmyers
joshmyersalmost 8 years ago
So that is the problem. The error when wanting to create the SG is not bubbling up through the code and the SG isn’t actually created because of above error parsing the CIDR address which is actually a subnet
joshmyers
joshmyersalmost 8 years ago
and the error you are receiving instead is just saying I can’t find that SG id
joshmyers
joshmyersalmost 8 years ago
fix the ^^ error with CIDR and try re running without the depends_on and with aws_efs_mount_target uncommented
rohit
rohitalmost 8 years ago
i think that fixed the issue
rohit
rohitalmost 8 years ago
@joshmyers thanks
rohit
rohitalmost 8 years ago
also, i am not able to view output variables
joshmyers
joshmyersalmost 8 years ago
Are you outputting the variables?
rohit
rohitalmost 8 years ago
yes
rohit
rohitalmost 8 years ago
for efs, i am now facing the following issue
rohit
rohitalmost 8 years ago
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[0]: 1 error(s) occurred:

* aws_efs_mount_target.kitemedia.0: MountTargetConflict: mount target already exists in this AZ
	status code: 409, request id: 74cdca17-fc8a-11e8-bdb0-d7feddd82bcc
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[11]: 1 error(s) occurred:

* aws_efs_mount_target.kitemedia.11: MountTargetConflict: mount target already exists in this AZ
	status code: 409, request id: 7eca3ec0-fc8a-11e8-b0cb-e76fd688df15
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[4]: 1 error(s) occurred:

* aws_efs_mount_target.kitemedia.4: MountTargetConflict: mount target already exists in this AZ
	status code: 409, request id: 755597d2-fc8a-11e8-a0c5-25395ed55c14
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[24]: 1 error(s) occurred:
joshmyers
joshmyersalmost 8 years ago
What is var.aws_azs set to?
joshmyers
joshmyersalmost 8 years ago
It looks like that count is way higher than I’d imagine the number of AZs available…
rohit
rohitalmost 8 years ago
@joshmyers you were correct
rohit
rohitalmost 8 years ago
i updated the count to use the length
rohit
rohitalmost 8 years ago
count = "${length(split(",", var.aws_azs))}"
rohit
rohitalmost 8 years ago
but i still get 2 errors
rohit
rohitalmost 8 years ago
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[2]: 1 error(s) occurred:

* aws_efs_mount_target.kitemedia.2: MountTargetConflict: mount target already exists in this AZ
	status code: 409, request id: c11d8b5d-fc8c-11e8-a6ac-03687caf52eb
* module.storage.module.kitemedia.aws_efs_mount_target.kitemedia[0]: 1 error(s) occurred:

* aws_efs_mount_target.kitemedia.0: MountTargetConflict: mount target already exists in this AZ
	status code: 409, request id: c11db25f-fc8c-11e8-adc4-b7e10e019ae2
joshmyers
joshmyersalmost 8 years ago(edited)
Any reason not to declare aws_azs as a list, rather than csv?
joshmyers
joshmyersalmost 8 years ago
and have they actually been created already but not written to the Terraform state?
joshmyers
joshmyersalmost 8 years ago
If so, manually delete the EFS mount targets and re run TF
rohit
rohitalmost 8 years ago
that worked
rohit
rohitalmost 8 years ago
@joshmyers thanks
rohit
rohitalmost 8 years ago
i am still not able to view the outputs
rohit
rohitalmost 8 years ago
i have them in outputs.tf
rohit
rohitalmost 8 years ago
output "kitemedia_dns_name" {
  value = "${aws_efs_file_system.kitemedia.id}.efs.${var.aws_region}.<http://amazonaws.com|amazonaws.com>"
}
rohit
rohitalmost 8 years ago
when i run terraform output kitemedia_dns_name
rohit
rohitalmost 8 years ago
The state file either has no outputs defined, or all the defined
outputs are empty. Please define an output in your configuration
with the `output` keyword and run `terraform refresh` for it to
become available. If you are using interpolation, please verify
the interpolated value is not empty. You can use the
`terraform console` command to assist.
rohit
rohitalmost 8 years ago
this is what i am seeing
joshmyers
joshmyersalmost 8 years ago
Inspect the statefile - is ^^ correct and there are no outputs defined in there?
joshmyers
joshmyersalmost 8 years ago
and is that output in the module that you are calling?
rohit
rohitalmost 8 years ago
do i have to use fully qualified name ?
joshmyers
joshmyersalmost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit try just terraform output from the correct folder and see what it outputs
rohit
rohitalmost 8 years ago
when i navigate to the correct folder, i get
The module root could not be found. There is nothing to output.
rohit
rohitalmost 8 years ago
i am able to see them in the state file
rohit
rohitalmost 8 years ago
but not on the command line using terraform output
joshmyers
joshmyersalmost 8 years ago
@rohit again, are you outputting the value in the module, and then also in the thing which calls the module as my example above?
rohit
rohitalmost 8 years ago
yeah tried that
rohit
rohitalmost 8 years ago
still same issue
joshmyers
joshmyersalmost 8 years ago
Without being able to see any code
joshmyers
joshmyersalmost 8 years ago
¯\(ツ)/¯
rohit
rohitalmost 8 years ago
this is what i have inside outputs.tf under kitemedia module
output "kitemedia_dns_name" {
  value = "${aws_efs_file_system.kitemedia.id}.efs.${var.aws_region}.<http://amazonaws.com|amazonaws.com>"
}
rohit
rohitalmost 8 years ago
and then this is what i have inside outputs.tf that calls kitemedia module
output "kitemedia_dns_name" {
  value = "${module.storage.kitemedia.kitemedia_dns_name}"
}
joshmyers
joshmyersalmost 8 years ago
Where has “storage” come from in module.storage.kitemedia.kitemedia_dns_name
joshmyers
joshmyersalmost 8 years ago
Please post full configs including all vars and outputs for both the module and the code calling the module in a gist
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit what IDE/Editor are you using?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
suggest to try https://www.jetbrains.com/idea/, it has a VERY nice Terraform plugin, shows and highlights all errors, warning, and other inconsistencies like wrong names, missing vars, etc.
joshmyers
joshmyersalmost 8 years ago
vscode is actually quite nice too - never thought I’d say that about an MS product but times are a changin’
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yea, i tried it, it’s nice
joshmyers
joshmyersalmost 8 years ago
Also has good TF support
rohit
rohitalmost 8 years ago
i am using vscode
Jan
Janalmost 8 years ago
im using vscode too, works well enough
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yep
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
just tried to understand where storage comes from in module.storage.kitemedia.kitemedia_dns_name as @joshmyers pointed out
rohit
rohitalmost 8 years ago
It's actually module.kitemedia.kitemedia_dns_name
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Working now?
rohit
rohitalmost 8 years ago
nope
rohit
rohitalmost 8 years ago
i am not sure what's wrong
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
can you post the full code?
rohit
rohitalmost 8 years ago
i will try
rohit
rohitalmost 8 years ago
i have another question
rohit
rohitalmost 8 years ago(edited)
so i have the following structure,
modules/compute/app1/main.tf, modules/compute/app2/main.tf, modules/compute/app3/main.tf
rohit
rohitalmost 8 years ago(edited)
i want to use an output variable from modules/compute/app1/main.tf in modules/compute/app2/main.tf
rohit
rohitalmost 8 years ago
so i am writing my variable to outputs.tf
rohit
rohitalmost 8 years ago
now, how do i access the variable in modules/compute/app2/main.tf ?
rohit
rohitalmost 8 years ago
does this makes sense ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it’s easy if all of those folders are modules, then you use a relative path to access the module and use its outputs, e.g. https://github.com/cloudposse/terraform-aws-eks-cluster/blob/master/examples/complete/main.tf#L62
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
if those apps are just resources, then you can use https://www.terraform.io/docs/providers/terraform/d/remote_state.html
Dan
Danalmost 8 years ago
anyone installing gitlab omnibus with terraform?
Jan
Janalmost 8 years ago
Im running gitlab form within k8s
Jan
Janalmost 8 years ago
oh thats the ee
Jan
Janalmost 8 years ago
sec
Dan
Danalmost 8 years ago
yea i saw the forum on
Dan
Danalmost 8 years ago
one
Dan
Danalmost 8 years ago
i didnt know if someone had the full stack
Dan
Danalmost 8 years ago
the vpc and subnets and everthing is easy
Dan
Danalmost 8 years ago
is that piece he has all i need hten?
Jan
Janalmost 8 years ago
Im not sure sorry, just found that
Jan
Janalmost 8 years ago
as much as possible I try to do things in k8s
Dan
Danalmost 8 years ago
yea i need to do that too!
Dan
Danalmost 8 years ago
do you have it for k8? @Jan
rohit
rohitalmost 8 years ago
In launch template, is it possible to set latest version to default ?
davidvasandani
davidvasandanialmost 8 years ago
Dan
Danalmost 8 years ago
@davidvasandani I'm looking for terraform that autocreates gitlab omnibus... if its not out there i just thought about writing it
davidvasandani
davidvasandanialmost 8 years ago
@Dan and you’re looking for AWS? I just checked Gitlab’s website and found they have a Terraform bootstart for GCE but it hasn’t be updated in a year.
Dan
Danalmost 8 years ago
yea for aws
Dan
Danalmost 8 years ago
i was thinking about converting the gce one
davidvasandani
davidvasandanialmost 8 years ago
Dan
Danalmost 8 years ago
thank you!
rohit
rohitalmost 8 years ago
In launch template, is it possible to set latest version to default ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
probably using that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

latest_version - The latest version of the launch template.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(haven't personally dealt with it lately)
rohit
rohitalmost 8 years ago
i was able to use latest_version in autoscalinggroup but i was not able to set newly created version on the launch template as default
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
hrm… @Maarten van der Hoef might have some ideas
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
@rohit Passing the baton to @Jamie Nelson (BitFlight) who worked with launch templates earlier, maybe he knows a bit more.
What do you mean with "not able to set newly created version on the launch template as default". Did you get a kind of error or you didn't notice a change ?
When updating a launch config of an autoscaling group the launch config has been changed but you won't see immediate effect. AWS does not do the replacement of the instances itself. Best way to tackle that is either a separate blue/green deployment deployment process or to something like step functions together with a lambda which takes care of that.
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
you can actually configure the autoscaling group to do a graceful replacement of the instances without using lambda
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
this thread isn't readable, is this the thread with the cloudformation resource ?
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
Haha. No it’s one of the lead terraform devs talking about how they do it for their own servers
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago


resource "aws_launch_configuration" "someapp" {
  lifecycle { create_before_destroy = true }

  image_id       = "${var.ami}"
  instance_type  = "${var.instance_type}"
  key_name       = "${var.key_name}"
  security_group = ["${var.security_group}"]
  
}

resource "aws_autoscaling_group" "someapp" {
  lifecycle { create_before_destroy = true }

  name                 = "someapp - ${aws_launch_configuration.someapp.name}"
  launch_configuration = "${aws_launch_configuration.someapp.name}"
  desired_capacity     = "${var.nodes}"
  min_size             = "${var.nodes}"
  max_size             = "${var.nodes}"
  min_elb_capacity     = "${var.nodes}"
  availability_zones   = ["${split(",", var.azs)}"]
  vpc_zone_identifier  = ["${split(",", var.subnet_ids)}"]
  load_balancers       = ["${aws_elb.someapp.id}"]
}


The important bits are:

* Both LC and ASG have create_before_destroy set
* The LC omits the "name" attribute to allow Terraform to auto-generate a random one, which prevent collisions
* The ASG interpolates the launch configuration name into its name, so LC changes always force replacement of the ASG (and not just an ASG update).
* The ASG sets "min_elb_capacity" which means Terraform will wait for instances in the new ASG to show up as InService in the ELB before considering the ASG successfully created.

The behavior when "var.ami" changes is:

(1) New "someapp" LC is created with the fresh AMI
(2) New "someapp" ASG is created with the fresh LC
(3) Terraform waits for the new ASG's instances to spin up and attach to the "someapp" ELB
(4) Once all new instances are InService, Terraform begins destroy of old ASG
(5) Once old ASG is destroyed, Terraform destroys old LC

If Terraform hits its 10m timeout during (3), the new ASG will be marked as "tainted" and the apply will halt, leaving the old ASG in service.
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
I know this isn’t answering rohits question.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Doesn't this also imply that all dependencies of the asg also need to have create_before_destroy then ?
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
I expect so.
Jan
Janalmost 8 years ago
that is how create_before_destroy works isnt it
Jan
Janalmost 8 years ago
fort a 3az, 2 tier vpc
Jan
Janalmost 8 years ago
ideally I will not have the same size public / private subnets
Jan
Janalmost 8 years ago
but have say 2/3 of the cidr for the vpc in private
joshmyers
joshmyersalmost 8 years ago
The above method of blue/green TF deploys of new AMIs works well, fails safe 👍️
Nikola Velkovski
Nikola Velkovskialmost 8 years ago
Only if you use ami baking and no docker 🙂 though.
Jan
Janalmost 8 years ago
So the max_subnets as a way to calculate subnets used in https://github.com/cloudposse/terraform-aws-multi-az-subnets has an interesting side effect
Jan
Janalmost 8 years ago
a /22 sent to a 3az vpc would by default create subnets with /26 rather than /25
Jan
Janalmost 8 years ago
this is because the max_subnets default of 6 means that the /22 need to fit 6*(number of tiers)
Jan
Janalmost 8 years ago
so its in fact max_subnets_per tier
Jan
Janalmost 8 years ago
not max per vpc
Jan
Janalmost 8 years ago
so max_subnets = 3 nets 8 subnets so 6x /25's
Jan
Janalmost 8 years ago
much less waste
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
@Jan the two subnet modules were created to divide a VPC into private and public subnets according to some set of rules (different for the two modules). It was already brought to attention that they ‘waste’ IP space and in general don’t provide all possible solutions. We mostly use https://github.com/cloudposse/terraform-aws-dynamic-subnets for all our deployments and it works well
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
if you have some specific requirements on how to divide a VPC not covered by any of the modules, then a new module needs to be created
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
there is a million ways to divide a vpc
Jan
Janalmost 8 years ago
Im already all sorted thanks
Jan
Janalmost 8 years ago
I just call it with max_subnets = 3
Jan
Janalmost 8 years ago
cheers for following up though
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
which module did you end up using?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Jan
Janalmost 8 years ago
Have you got an example of using https://github.com/cloudposse/terraform-aws-dynamic-subnets to do a two tier 3az vpc?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
two tier means private and public subnets?
Jan
Janalmost 8 years ago
yes
Jan
Janalmost 8 years ago
spanning 3 availability zones
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
but that’s what we use everywhere
Jan
Janalmost 8 years ago
maybe I missed something then
Jan
Janalmost 8 years ago
right
Jan
Janalmost 8 years ago
I see
Jan
Janalmost 8 years ago
cool thanks, will switch over to that one
Jan
Janalmost 8 years ago
and test
rohit
rohitalmost 8 years ago(edited)
@Maarten van der Hoef I am able to use newly created launch template version to create autoscaling group but on the launch template there is an option to set the default version which i am not able to do for the latest version using terraform
rohit
rohitalmost 8 years ago
and no, i don't get an error
rohit
rohitalmost 8 years ago
I just don't see an option to do it in terraform
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
not sure if that’s the correct way of doing it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
(and that’s not suited for green/blue deployments as @Jamie Nelson (BitFlight) and @Maarten van der Hoef discussed)
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) i saw this but this will only set the autoscaling group to use the latest version
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
yes, that is on the autoscaling group
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so i guess it should be version = "$$Default"
rohit
rohitalmost 8 years ago
but i am talking about setting the default version on launch_template
rohit
rohitalmost 8 years ago
which has nothing to do with autoscaling group
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Maybe it's not configurable, but something the WEBUI team came up with after smoking something. Just deep dive here https://github.com/aws/aws-sdk-go to see if it's in their api.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
aws ec2 modify-launch-template --launch-template-id "lt-0444afefe36b9f2c0" --default-version "1" --region eu-central-1
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
ok, so there is a command line for it, that helps 🙂
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
ok, so you can set the default version with it, meaning that if you launch a template without giving the version it will take the default one.
I'm not so sure why you would want that with Terraform as you control the whole chain with Terraform anyway and thus can pick the launch configuration you made with Terraform.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yea thanks @Maarten van der Hoef
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the default version will be used if you don’t specify any version
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
anyway it’s better to recreate the template and ASG if any changes
Jan
Janalmost 8 years ago
ending up with x-xx-subnet-private-eu-central-1b & x-xx-xxx-public-eu-central-1b
Jan
Janalmost 8 years ago
x, xx, xxx brin vars im setting namespace, stage, name
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
no, it’s a bug (regression after the last updates to the module)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
thanks for finding it
Jan
Janalmost 8 years ago
👍️
Jan
Janalmost 8 years ago
just looked out of place
Jan
Janalmost 8 years ago
Far nicer subnet module btw
Jan
Janalmost 8 years ago
still passing max_subnet_count = 3
Jan
Janalmost 8 years ago
also decided on availability_zones = ["${slice(data.aws_availability_zones.available.names, 0, 3)}"]
Jan
Janalmost 8 years ago
for now
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yea
Jan
Janalmost 8 years ago
but im getting expected results
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it was designed to take all AZs into account
Jan
Janalmost 8 years ago
yea I saw
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
that’s why it divides into smaller subnets
Jan
Janalmost 8 years ago
which I guess makes sense
Jan
Janalmost 8 years ago
so I mean thats 100% valid in that context
Jan
Janalmost 8 years ago
though I dont use any region with less than 3az and build my k8s clusters around that choice
Jan
Janalmost 8 years ago
will explroe that later
Jan
Janalmost 8 years ago
an easy change
Jan
Janalmost 8 years ago
Just got a vpn gw and cgw working
Jan
Janalmost 8 years ago
😄
Jan
Janalmost 8 years ago
So I guess new module incoming soon then
rohit
rohitalmost 8 years ago
Is it possible to create a target group without creating elb ?
ikar
ikaralmost 8 years ago
Hi there, I'm new to terraform (used it to make ec2 instace 💪).
I'm trying to use this module: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn
...well to create cloudfront with s3 source 😉
we don't have any domain and with this code:

module "cdn" {
  source = "cloudposse/cloudfront-s3-cdn/aws"
  version = "0.3.5"
  stage = "dev"
  name = "app"
  namespace = "pg"
}

I get this error:

...
module.cdn.data.aws_iam_policy_document.origin: Refreshing state...
module.cdn.module.logs.aws_s3_bucket.default: Creation complete after 4s (ID: pg-dev-pg-app-logs)

Error: Error applying plan:

1 error(s) occurred:

* module.cdn.aws_s3_bucket.origin: 1 error(s) occurred:

* aws_s3_bucket.origin: Error putting S3 CORS: MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
        status code: 400, request id: 8E821E105B6852CA, host id: F+zK01RI/I3BcuzlnK+nRLEdvLz4G4bRkJgGutEYI8fS4iBNTGw7UGLWik+GtLcCyvqXQxMcecU=

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

this sounds quite cryptic to me, any idea where to start digging?
joshmyers
joshmyersalmost 8 years ago
@ikar have you run this with debug logging turned on?
ikar
ikaralmost 8 years ago
nope, didn't know about the possibility, thanks! But it seems the module requires at least cors_allowed_origins = ["*"]. Though hit another problem which probly can't be solved using that module, will write s3+cdn by myself from scratch.
ikar
ikaralmost 8 years ago
yes, that is way more complicated than what I need (no route 53). also don't need logging
joshmyers
joshmyersalmost 8 years ago
you probably do want logging…
joshmyers
joshmyersalmost 8 years ago
joshmyers
joshmyersalmost 8 years ago
but I’m thinking https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf#L64 maybe breaking if nothing at all is set
ikar
ikaralmost 8 years ago
not at this point. yes, it says it is optional, but ends with the error above
joshmyers
joshmyersalmost 8 years ago
Turn on debug logging and see if there is a broken looking cors config
ikar
ikaralmost 8 years ago
how to do that?
ikar
ikaralmost 8 years ago
holy cow! that's a lot of debug info 😃
Jan
Janalmost 8 years ago
hahah yea debug is brutal
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@ikar if you still having the issue, paste your complete code here and we’ll take a look
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Welcome to the community btw :)
ikar
ikaralmost 8 years ago
thanks @Andriy Knysh (Cloud Posse)! creating custom module, but thanks 😉
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Are you creating Cloudfront with plain S3 bucket as origin, or as a website?
ikar
ikaralmost 8 years ago
Cloudfront with plain S3 bucket as origin
davidvasandani
davidvasandanialmost 8 years ago
@ikar it'll be easier for the community to help you modify one of the existing modules (and more useful to the community as a whole) vs writing a brand new module from scratch. Good luck either way though!! 🙌🏻
ikar
ikaralmost 8 years ago
I wanted to try custom solution to learn about terraform. The thing is I wasn't able to setup CDN behaviour correctly using this: <https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn>
ikar
ikaralmost 8 years ago
by "correctly" I mean as requested by a project manager
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
davidvasandani
davidvasandanialmost 8 years ago
@ikar if you can go into more detail of what the module is failing to configure maybe we can help you. Possibly by turning a current static configuration into something more dynamic for your and others needs.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this combined with atlantis would be a great way to allow community to contribute new modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
literally open up a PR for the terraform module repo
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
get it approved, merged
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
then contribute your changes
loren
lorenalmost 8 years ago
nifty idea!
sarkis
sarkisalmost 8 years ago
or even providers...
loren
lorenalmost 8 years ago
i'd dearly love an official okta provider...
Jan
Janalmost 8 years ago
Interesting idea
Jan
Janalmost 8 years ago
“Introducing Aardvark and Repokid” by Netflix Technology Blog https://link.medium.com/ZoHsIudfBS
Jan
Janalmost 8 years ago
Along with Netflix Aardvark and Repokid could prove to be a sweet trio
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

access profiling and automated and ongoing right-sizing. We allow developers to deploy their applications with a basic set of permissions and then use profiling data to remove permissions that are demonstrably not used.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I've wanted to do exactly this!
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
I was thinking it would be nice to run terraform through an AWS API proxy and then turn parse the requests to figure out the canned permissions
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
terraform-aws-permissions-generator seems kind of like that
Jan
Janalmost 8 years ago
https://github.com/duo-labs/cloudmapper has a super interesting feature with audit usage
Jan
Janalmost 8 years ago
Being some one that has always understood infrastructure sets in a visual and conceptual way it pretty cool
Jan
Janalmost 8 years ago
Still exploring it
Jan
Janalmost 8 years ago
Jan
Janalmost 8 years ago
Is also pretty neat
Shane
Shanealmost 8 years ago
@Jan oh, that's interesting we just had someone last week run... terraform destroy --force on our folder that contains all of our dev infrastructure 🙂
Shane
Shanealmost 8 years ago
Anyone have any recommendations for making that as least destructive as possible 😉. It stopped them when the IAM role they were using was deleted.
Shane
Shanealmost 8 years ago
Took us 30 mins to recover so it was a good exercise 😉
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
not really... maybe more sandbox accounts
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

terraform destroy --force on our folder that contains all of our dev infrastructure
Shane
Shanealmost 8 years ago
ya, one option is to seperate the dev folders by teams
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
though wait, you have the entire dev infra defined in one project?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
yea, exactly, more projects ~ states
Shane
Shanealmost 8 years ago
it's a single terraform project with about 2 dozen modules
Shane
Shanealmost 8 years ago
terraform state list | wc 571
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we've moved away from large projects mostly because they (a) take FOREVER to plan (b) have a huge blast radius
Shane
Shanealmost 8 years ago
we have basically been waiting for it to get slow to plan/apply, but it has been fine so we had no reason to split it out.
Shane
Shanealmost 8 years ago
but after the deletion that might give us a good reason 😉
Shane
Shanealmost 8 years ago
and it will also improve atlantis locks
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, exactly
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
here's roughly how we organize everything
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this will vary from company to company, team to team
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
each one of those folders in aws corresponds to a project
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
coldstart is pretty painful. we go into each folder and plan/apply
Shane
Shanealmost 8 years ago
ya, we essentially group our "projects/services" as modules unto themselves in their own git repo.
Shane
Shanealmost 8 years ago
So the main state just references modules with their variables.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, that's nice
Shane
Shanealmost 8 years ago
we use that setup to have CI tests that test out the modules on changes.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
are you using plain terraform for everything?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Shane
Shanealmost 8 years ago
Correct, no terragrunt
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
👍️
Shane
Shanealmost 8 years ago
I have never been overly fond of terragrunt.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
same
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
but this terraform init -from-module=.... is top of mind
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(incidentally, something terragrunt does use under the hood)
Shane
Shanealmost 8 years ago
ya, that's interesting functionality
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so i'd like to be able to define an architecture more or less without writing a line of terraform code
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
assuming all the modules already exist
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
anyways, that's what I think I want. not sure yet. 😃
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i have a call with Dans @ Uber next tuesday to learn more about how they use Astro at uber.
Shane
Shanealmost 8 years ago
nice
Shane
Shanealmost 8 years ago
Got ya, so define the modules and make them more resuable with a simple abstraction on top.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
yea... and since we're both helmfilers, basically something like #helmfile
johncblandii
johncblandiialmost 8 years ago
Take your time reviewing this monster PR: https://github.com/cloudposse/terraform-aws-eks-cluster/pull/7
sahil
sahilalmost 8 years ago
Hi guys, do we have a terraform module for cognito user pool? If not, do we have any plans for it in the future?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ah, bummer! no not yet.
johncblandii
johncblandiialmost 8 years ago
sorry…that’s data. 🙂
johncblandii
johncblandiialmost 8 years ago
that’s a lot of args. LOL. I can see where a module would help.
johncblandii
johncblandiialmost 8 years ago
#homerdisappear
johncblandii
johncblandiialmost 8 years ago
anyone k8s with EKS? trying to get my bearings and the auth is winning right now
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I saw your PR
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
have you looked at the examples/complete
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
that was tested as of a couple of days ago
johncblandii
johncblandiialmost 8 years ago
i didn’t. checking
johncblandii
johncblandiialmost 8 years ago
just pushed a fix, btw
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
thx!
johncblandii
johncblandiialmost 8 years ago
i have it running. it worked flawlessly
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Andriy Knysh (Cloud Posse) is most familiar with it
johncblandii
johncblandiialmost 8 years ago
Unauthorized is my life right now. i will go back through the setup steps
johncblandii
johncblandiialmost 8 years ago(edited)
got it. def’ was a config thing from the yaml output. i needed to use the AWS_PROFILE env var or update the config yaml to pass it into aws-iam-authenticator
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
🎉
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
awesome!
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
is this a skunkworks project to get off of beanstalk?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
😃
johncblandii
johncblandiialmost 8 years ago
somewhat, yeah. it is to deploy our new jenkins setup and a way to open eyes to using k8s
deftunix
deftunixalmost 8 years ago
hi everyone, I am developing a terraform provider for Ansible AWX (a.k.a. Tower).
deftunix
deftunixalmost 8 years ago
if anyone is interested or wants contribute to the project, it is warmed welcome
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@deftunix looks interesting, thanks for sharing. I’ll take a look in more details
Dan
Danalmost 8 years ago
what are people using instead of beanstalk? are you just creating web instances on a docker cluster and then using api gatway or somthing
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
@Dan so depending on your requirements and many other considerations, and speaking only about AWS, it could be Beanstalk (but it’s like creating a cluster for each app), ECS, EKS, or kops. You can deploy any web app on a Kubernetes cluster, no need to use API gateway (although it could be used, but serves diff purpose). You deploy the app containers on k8s, use nginx-ingress for ingress, and ELB/ALB and Route53 for routing/DNS
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
for ECS, take a look at the very nice implementation here https://airship.tf (thanks to @Maarten van der Hoef)
Dan
Danalmost 8 years ago
interesting
Dan
Danalmost 8 years ago
thank you!
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
also, Fargate could be a nice solution in some cases
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so it’s one of Beanstalk, ECS, Fargate (currently just for ECS), EKS, kops - each has pros and cons
Dan
Danalmost 8 years ago
yea that makes sense
johncblandii
johncblandiialmost 8 years ago
@Andriy Knysh (Cloud Posse) do you know why workers would not have access to the cluster when running terraform-aws-eks-cluster/workers?
johncblandii
johncblandiialmost 8 years ago
“No resources found.” has none found
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
johncblandii
johncblandiialmost 8 years ago
yeah
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
EKS currently does not support for the master to join the cluster automatically
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you have to apply the config
johncblandii
johncblandiialmost 8 years ago
i did
johncblandii
johncblandiialmost 8 years ago
the configmap, right?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it could be done manually, or automatically
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago

If you want to automatically apply the Kubernetes configuration, set var.apply_config_map_aws_auth to “true”
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yes configmap
johncblandii
johncblandiialmost 8 years ago
configmap/aws-auth unchanged
johncblandii
johncblandiialmost 8 years ago
still no nodes found
johncblandii
johncblandiialmost 8 years ago
do i need to restart the workers after?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
i did not restart them
rohit
rohitalmost 8 years ago
Does anyone here use cloudflare for dns cert validation ?
rohit
rohitalmost 8 years ago
Everytime i run a plan i see that it wants to update in-place the entry in cloudflare
cloudflare_record.dns_cert_validation
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so it doesn’t make sense to me why you do the DNS validation for ACM with cloudflare
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
cloudflare has it’s own TLS certificates
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
and cloudflare works like MITM not passthru
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@johncblandii when you run kubectl get nodes using the generated kubeconfig file, what do you see?
jeffrey
jeffreyalmost 8 years ago
Has anyone here experienced an issue with permissions after generating an aws key pair through terraform? I have an elastic beanstalk environment and application that needs an ssh key attached. everything runs smoothly if i generate the key pair through the console and specify the hard-coded name to EC2KeyName. however, if I generate the aws key pair using https://github.com/cloudposse/terraform-aws-key-pair, i get an error about the role policy not having the proper permissions
johncblandii
johncblandiialmost 8 years ago
why do the Makefile’s download a tf version? why not use my local one?
johncblandii
johncblandiialmost 8 years ago

/Library/Developer/CommandLineTools/usr/bin/make terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
Installing Terraform 0.10.7 (darwin) from <https://releases.hashicorp.com/terraform/0.10.7/terraform_0.10.7_darwin_amd64.zip>
######################################################################## 100.0%
/Users/john.bland/Work/terraform-aws-efs/build-harness/vendor/terraform version
Terraform v0.10.7

Your version of Terraform is out of date! The latest version
is 0.11.10. You can update by downloading from <http://www.terraform.io/downloads.html|www.terraform.io/downloads.html>
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so we sandbox everything in the build-harness
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
only way to have a chance of escaping the “works on my machine” syndrome
johncblandii
johncblandiialmost 8 years ago
coolio
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
what command were you trying to run?
johncblandii
johncblandiialmost 8 years ago
any reason it isn’t using the latest version?
johncblandii
johncblandiialmost 8 years ago
make init
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
hrm
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
surprised we install terraform on make init
johncblandii
johncblandiialmost 8 years ago
sorry…lint
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
aha, ok that make more sense.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we don’t have an automated process yet for opening PRs to bump versions
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I want to add it to our cloudposse/packages
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
for now, i’ll open an issue and we’ll get that version bumped
johncblandii
johncblandiialmost 8 years ago
gotcha
johncblandii
johncblandiialmost 8 years ago
what’s the secret sauce to run before pushing?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
oh, for the docs?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
make readme
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(assumes at some point you’ve run make readme/deps)
johncblandii
johncblandiialmost 8 years ago
yup. got that one
johncblandii
johncblandiialmost 8 years ago
thought there was another too, but seems that did ok
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
fmt?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
terraform fmt
johncblandii
johncblandiialmost 8 years ago
clear there
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
check the .travis.yml for all the steps
johncblandii
johncblandiialmost 8 years ago
cool. just don’t want to waste your time when I put the PR up
johncblandii
johncblandiialmost 8 years ago
🙂
johncblandii
johncblandiialmost 8 years ago
ah, good to know
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
haha, appreciated it!
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
make init
make readme/deps
make readme
johncblandii
johncblandiialmost 8 years ago
cool
johncblandii
johncblandiialmost 8 years ago
thoughts?
johncblandii
johncblandiialmost 8 years ago
pushed a quick update on the readme
johncblandii
johncblandiialmost 8 years ago
btw, example might need some work
johncblandii
johncblandiialmost 8 years ago
let me actually make those changes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Thanks
johncblandii
johncblandiialmost 8 years ago
np
johncblandii
johncblandiialmost 8 years ago
pushed
johncblandii
johncblandiialmost 8 years ago
ran it within my eks work and it worked
erik
erikalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
@Dombo thanks! 😃
Dan
Danalmost 8 years ago
Okay I'm going crazy
Dan
Danalmost 8 years ago
Why isn't this working
Dan
Danalmost 8 years ago
variable "allowed_ports" {
type = "list"
description = "List of allowed ingress ports"
default = ["22","88"]
}
Dan
Danalmost 8 years ago
from_port = "${element(var.allowed_ports, count.index)}"
to_port = "${element(var.allowed_ports, count.index)}"
Dan
Danalmost 8 years ago
It only adds port 22 to sg
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
use count
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
show the whole module where you have
from_port         = "${element(var.allowed_ports, count.index)}"
 to_port           = "${element(var.allowed_ports, count.index)}"
Dan
Danalmost 8 years ago
Ah let me add thay
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you use count in the resource, and then you can use count.index
Dan
Danalmost 8 years ago
I think I got it!
Dan
Danalmost 8 years ago
Having some other route table shennigans now
Dan
Danalmost 8 years ago
I know what's up
Dan
Danalmost 8 years ago
Do you have an example of running a bunch of Linux commands on a box through a tpl file?
Dan
Danalmost 8 years ago
Thank you!
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
anyone here send EC2 instance status events (cloudwatch + sns +lambda) to slack?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
like those hardware failure notices, scheduled maintenance, etc
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we have the module for sns<->slack
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we're missing the cloudwatch side
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
@Jamie Nelson (BitFlight) or @Maarten van der Hoef might have something
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
Is there a way to define the order in which output variables display ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
not really
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
i think that if you put them all in the same file, they will output in that order they appear (but just a hunch)
rohit
rohitalmost 8 years ago
they don't appear in the same order
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
hrm…
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
then I don’t think there is a way “out of the box”
rohit
rohitalmost 8 years ago
not a big deal, thought there would be something already available to do this
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
you can emit them in json and then do what ever you want (E.g. with jq)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
terraform output -format=json | jq ...
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(or something like that)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
rohit
rohitalmost 8 years ago
nice
rohit
rohitalmost 8 years ago
that works for me
rohit
rohitalmost 8 years ago
thanks
johncblandii
johncblandiialmost 8 years ago(edited)
isn’t it just in alphabetical order?
rohit
rohitalmost 8 years ago
yes it is
Shane
Shanealmost 8 years ago
You are about 3 days late on that
johncblandii
johncblandiialmost 8 years ago
Question: when moving state (due to a refactor of my files/approach), what’s the proper format? I’m trying to automate it with a simple ruby script.

Inside is basically the efs, eks_cluster, and eks_workers module in the modules/cluster and the route53 module in modules/route53. Previously I ran the whole thing from the modules folder as it wasn’t expected to grow in the way it did, but it continues to grow so I moved them to modules with a root level project to kick it all off.

Any thoughts would be appreciated.

New structure:

├── modules
│   ├── cluster
│   │   ├── efs.tf
│   │   ├── kubectl.tf
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── variables.tf
│   └── route53
│       ├── main.tf
│       ├── outputs.tf
│       └── variables.tf
 | main.tf


Old structure:

├── cluster
│   ├── efs.tf
│   ├── kubectl.tf
│   ├── main.tf
│   ├── outputs.tf
│   └── variables.tf
└── route53
|   ├── main.tf
|   ├── outputs.tf
|   └── variables.tf
joshmyers
joshmyersalmost 8 years ago
argh, moving state en mass is a pain if you have lots of resources
joshmyers
joshmyersalmost 8 years ago(edited)
What do you mean by proper format?
johncblandii
johncblandiialmost 8 years ago
the mv format
joshmyers
joshmyersalmost 8 years ago
Still not sure I follow. The format is as defined when you do a terraform state list
joshmyers
joshmyersalmost 8 years ago
joshmyers
joshmyersalmost 8 years ago
terraform state mv module.certificate.aws_route53_zone.default module.MY_RENAMED_MODULE.aws_route53_zone.default
loren
lorenalmost 8 years ago
just moving the files doesn't necessarily mean they will move in the state...
joshmyers
joshmyersalmost 8 years ago
Indeed
joshmyers
joshmyersalmost 8 years ago
The statefile has no idea how your files are ogranised. If you have changed resource names and don’t want Terraform to throw the old ones away and create your new ones, use state mv for example
loren
lorenalmost 8 years ago
yeah, renaming resources or modules inside your terraform config is when state mv comes into play. avoid that, and you should still be golden, regardless of how you organize the files
johncblandii
johncblandiialmost 8 years ago
so I’m moving the state as well
johncblandii
johncblandiialmost 8 years ago
state was in cluster/. I’m moving it to the root
loren
lorenalmost 8 years ago(edited)
local state, just a file in the repo? (i.e. no backend?)
johncblandii
johncblandiialmost 8 years ago
correct. just working locally right now
joshmyers
joshmyersalmost 8 years ago
Have you renamed any of your resources? e.g. aws_instance.foo -> aws_instance.bar ?
johncblandii
johncblandiialmost 8 years ago
nah, resources are the same except the root now has a module wrapping the module/cluster
johncblandii
johncblandiialmost 8 years ago(edited)
so module cluster -> modules/cluster -> eks, efs, etc
johncblandii
johncblandiialmost 8 years ago
module route53 -> modules/route53 -> route53
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Jamie Nelson (BitFlight) I noticed that "test kitchen" is by new context. Have you used it much over there?
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
Sadly no. The companies I’m working currently with are not coming from a test driven design background. So it’s not come up. But I read through the docs for this. And found a few others that were recommended through reddit threads.
Jamie Nelson (BitFlight)
Jamie Nelson (BitFlight)almost 8 years ago
Have you touched on it yet? Do you want to wrap it into the modules we are creating?
rbadillo
rbadilloalmost 8 years ago
Team, I have a question, do you guys know if it is possible to create a file in a terraform run and in the same run, execute it ?
rbadillo
rbadilloalmost 8 years ago
I’m using null_resource and local-exec
rbadillo
rbadilloalmost 8 years ago
but looks like it is not working
rbadillo
rbadilloalmost 8 years ago

resource "null_resource" "test_file" {
  provisioner "local-exec" {
    command = <<EOT
      cat > test.sh << EOF
echo "Success"
EOF
EOT
  }

}

resource "null_resource" "run_file" {
  provisioner "local-exec" {
    command = "bash test.sh"
  }

  depends_on = [
    "null_resource.test_file",
  ]
}
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rbadillo do you mean that when run_file gets executed, it could not find test.sh (depends_on = [“null_resource.test_file”,] not working)? or some other errors?
rbadillo
rbadilloalmost 8 years ago
it can’t find it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the file?
rbadillo
rbadilloalmost 8 years ago
correct
rbadillo
rbadilloalmost 8 years ago
can you try it on your side, please?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rbadillo
rbadilloalmost 8 years ago
amazing
rbadillo
rbadilloalmost 8 years ago
exactly what I’m doing
rbadillo
rbadilloalmost 8 years ago
EKS stuff
rbadillo
rbadilloalmost 8 years ago
thanks a lot
johncblandii
johncblandiialmost 8 years ago
I can vouch for the EKS stuff 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
🍻
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i thought there was a magic variable (like path.module) which referred to the module name itself (e.g. github repo)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
anyone have a tip to get it?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
e.g. inside the terraform-aws-eks-cluster module, is it possible to know I’m inside terraform-aws-eks-cluster? 😃
johncblandii
johncblandiialmost 8 years ago
Would path.cwd work?
loren
lorenalmost 8 years ago
Do you actually want to know the directory name, which could change if someone cloned into a custom directory, or do you want it to always be a specific value for a given module? If the latter, probably a local would be needed?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
in this case, the wanting to publish artifacts (zips of lambdas) to <http://artifacts.cloudposse.com/<module-name>/<git|artifacts.cloudposse.com/<module-name>/<git> hash>/lambda.zip
loren
lorenalmost 8 years ago(edited)
Maybe split path.module on / and take the last element?
loren
lorenalmost 8 years ago(edited)
Oh, or just dirname(path.module), better for cross-platform support too
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
but modules are checked out to hashed folders
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(probably git hash)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
..checked out by terraform init
loren
lorenalmost 8 years ago
Then back to a local you define in each module :p
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, that may be the best bet
antonbabenko
antonbabenkoalmost 8 years ago
I really like this one - https://github.com/cloudposse/terraform-aws-ecs-container-definition , because I was missing some properties like secrets in this one - https://github.com/blinkist/terraform-aws-airship-ecs-service/tree/master/modules/ecs_container_definition . Good job with all this ECS pieces.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, someone just contributed the secrets piece last week (i think)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
thanks 😃
loren
lorenalmost 8 years ago(edited)
At the very least, you can get unblocked using a local, and then if someone figures out the magic sauce you can just adjust the local
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
yep, easy peasy to update local
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
@antonbabenko you can also just use my module in your atlantis one 😉
antonbabenko
antonbabenkoalmost 8 years ago
I am really-really trying to use parts of your ECS modules in my current project. Some pieces fit well, but some I have to copy-paste.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
That's fine 🙂
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Ask in the #airship channel in case you have questions 🙂
antonbabenko
antonbabenkoalmost 8 years ago
I will, but my case is rather straightforward. I really recommend to add documentation and working examples. Working examples with just single terraform apply is critical to get people on board.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
That's work in progress at the moment, almost there.
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
Finishing the Per Module Guides now, after that I'll work out some use-cases.
S
SweetOpsalmost 8 years ago
Are you using some of our terraform-modules in your projects? Maybe you could leave us a testimonial! It means a lot to us to hear from people like you.
antonbabenko
antonbabenkoalmost 8 years ago
“Thank you for your testimonial!“ 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
thanks anton!!! 😃
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ugh - devil is in the details
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

The given URL may be either an http or https URL. At present this resource can only retrieve data from URLs that respond with text/* or application/json content types, and expects the result to be UTF-8 encoded regardless of the returned content type header.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so we cannot use it to download zips
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
unless we do something retarded and base64 encode them
loren
lorenalmost 8 years ago
Yep, I made an external module to create a local filecache to work around that, but it's less than ideal for sure
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
aha, so you ended up writing an a script in python that you call from terraform
loren
lorenalmost 8 years ago
Yup
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
though the dependency on external pip modules makes it more difficult to use as a drop-in module
loren
lorenalmost 8 years ago
The requirements aren't gonna change, you can pip install six and boto3 any way you like
loren
lorenalmost 8 years ago
I use a terragrunt hook myself, but any task runner could do it
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
thanks for this! you gave me an idea for how I’m going to attempt it
loren
lorenalmost 8 years ago
👍️
erik
erikalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)

data "external" "curl" {
  program = ["curl", "-sSL", "--write-out", "{\"success\": \"true\"}", "-o", "${local.output_file}", "${local.url}"]
}
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
while this still requires an external app (curl), it’s installed by default on many systems.
loren
lorenalmost 8 years ago
Haha nice! Yeah, I had a hard req on s3 support and cross-platform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
s3:// urls?
loren
lorenalmost 8 years ago
Yep
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ah, yea, that makes it harder.
loren
lorenalmost 8 years ago(edited)
And I had already written the python module for another project, soooo
loren
lorenalmost 8 years ago
I should probably just publish that as its own package, I've reused it so many times now
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i kind of wish terraform would support more escape hatches
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
it will reduce some of the pressure on them
loren
lorenalmost 8 years ago
Agreed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
i wish there was a simple interpolation of exec
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the expectation that data.external needs JSON output should be loosened to text or json
loren
lorenalmost 8 years ago
A return format argument would be handy
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
published https://github.com/cloudposse/terraform-external-module-artifact to download binary artifacts from http(s) endpoints (e.g. useful for public lambda zips)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
Samant Maharaj
Samant Maharajalmost 8 years ago
Hi everyone. I'm trying to use https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment but I need to use a network load balancer.
Samant Maharaj
Samant Maharajalmost 8 years ago
Samant Maharaj
Samant Maharajalmost 8 years ago
Is there any way to override these values from my main.tf given I'm importing the module with the source pointing at GitHub?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Hi @Samant Maharaj welcome
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
looks like those are hardcoded
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so if you want to add support to other values, they needs to be converted to variables
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you can clone/fork the repo and test with your values, then open a PR against the cloudposse repo
Samant Maharaj
Samant Maharajalmost 8 years ago
OK thanks. Still a little new to Terraform so I wasn't sure if it was possible to override them after importing the module.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
so yea, if you clone the repo to your computer, you can set the values to whatever you want for testing - the fastest way to test it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
if you cd to examples/complete, you could run terraform init/plan/apply to test from the example
Samant Maharaj
Samant Maharajalmost 8 years ago
👍️
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
source    = "../../"
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
to use the module’s code from your computer
johncblandii
johncblandiialmost 8 years ago
@Samant Maharaj does it not work when you pass in loadbalancer_type?
johncblandii
johncblandiialmost 8 years ago
Trex
Trexalmost 8 years ago
Hi guys, I’m trying to setting cloudwatch-sns alarm via terraform.
I come across with https://github.com/cloudposse/terraform-aws-rds-cloudwatch-sns-alarms

However, once apply to a single RDS, the terraform record the “snapshot” in the tfstate file. When I try to apply to another RDS, it warn that it will delete the first setup and create new resources for second RDS.

Anyone has ideas on how to make the alarm reusable for multiple RDS instance?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ohhhhhhh
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Trex you are correct - this is an oversight
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the resource names are not using labels (@Jamie Nelson (BitFlight) 😜 )
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
we haven’t had a chance to get back to this
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Trex would you be open to contributing back a PR?
loren
lorenalmost 8 years ago
grrr, hate this error so much...

value of 'count' cannot be computed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
🤯
Nikola Velkovski
Nikola Velkovskialmost 8 years ago(edited)
ah I've seen that one, when you use count in locals teffaform doesn't compute it immediatelly
loren
lorenalmost 8 years ago
i know why it's happening, it's just super frustrating 😕
Nikola Velkovski
Nikola Velkovskialmost 8 years ago
yes it is 😞
jeffrey
jeffreyalmost 8 years ago
hey guys, i'm currently using this module (https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/blob/master/main.tf) or a slight variation of it given that I need to start multiple elastic beanstalk applications & environments with the same iam role and service roles. therefore i pulled out any IAM related resources out and use implicit dependencies to pass into the creation of the beanstalk apps and environments.

however, sometimes i'm getting an error about ELB health failing which is caused by the proper role and policy attachments not being attached in time. it seems like there's a race condition going on because it succeeds about 25% of the time. have any of you encountered this before?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@jeffrey please share the complete code, we’ll take a look (difficult to say anything w/o seeing the code)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago

it succeeds about 25% of the time
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
is that during terraform apply?
davidvasandani
davidvasandanialmost 8 years ago
@jeffrey would it be alright if we helped you modify the existing module to accept an IAM role as a variable?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yep, and for backwards compatibility, we need to check if a role was provided and use it, otherwise fall back to creating a new one
jeffrey
jeffreyalmost 8 years ago
apologize for the delayed response!

here's the module that calls elastic beanstalk application

module "api_server_app" {
  source                    = "../modules/app"
  beanstalk_app_description = "api server application"
  beanstalk_app_name        = "${var.stack_name}-api-server"
  iam_role_arn              = "${aws_iam_role.beanstalk_service.arn}"
}


where "../modules/app" contains the following:

resource "aws_elastic_beanstalk_application" "default" {
  description = "${var.beanstalk_app_description}"
  name        = "${var.beanstalk_app_name}"

  appversion_lifecycle {
    service_role          = "${var.iam_role_arn}"
    max_count             = 128
    delete_source_from_s3 = true
  }
}
jeffrey
jeffreyalmost 8 years ago(edited)
here's the module that calls the elastic beanstalk enviroment:

module "poms_api_server" {
  source     = "../modules/beanstalk"
  app        = "${module.poms_api_server_app.app_name}"
  keypair    = "${module.key.key_name}"
  stack_name = "${var.stack_name}"
  subnets    = "${join(",","${module.vpc.beanstalk_subnets}")}"
  vpc_id     = "${module.vpc.vpc_id}"

  # IAM
  instance_profile_name = "${aws_iam_instance_profile.beanstalk_ec2.name}"

  # LB
  service_role_arn = "${aws_iam_role.beanstalk_service.name}"
}


where the "../modules/beanstalk" only contains the elastic beanstalk environment code from https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/blob/master/main.tf (minus iam roles, security groups, s3 buckets, and the environment variables), and slight modifications in the variable naming
jeffrey
jeffreyalmost 8 years ago
@davidvasandani thanks - the existing module currently accepts the IAM role as a variable already. however, this is what I believe - i'm creating the iam role, then creating additional role policy attachments onto it for enhanced health and beanstalk service. however, the application is dependent on just the iam role and begins creation immediately when it's ready, but before the role policies have been fully created/attached
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago(edited)
another thing you can try is this:
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
here
instance_profile_name = "${aws_iam_instance_profile.beanstalk_ec2.name}"

  # LB
  service_role_arn = "${aws_iam_role.beanstalk_service.name}"
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
you use the names, but TF will calculate the names before the resources get created
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
if you use the IDs, then TF will wait for the resources to be created by AWS
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
(and you prob need to use arn here, not name): service_role_arn = “${aws_iam_role.beanstalk_service.arn}”
jeffrey
jeffreyalmost 8 years ago
oh awesome, i'll try those. so you suggest using ids in both these instances?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
well, in one
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
the other needs arn, no?
jeffrey
jeffreyalmost 8 years ago
within the service role i've tried the arn and the name before, both ran succesfully so i'm assuming it does a lookup
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
hmmm
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
but those are diff things
jeffrey
jeffreyalmost 8 years ago
i'll run through those again and make sure the resources being created are as expected. at the time, i was making sure the script was compiling correctly. appreciate the tips!
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
any one pretty familiar with cross-across terrraform with assumed roles?
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
think so yes
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

provider "aws" {
  alias = "testing"
  assume_role {
    role_arn = "arn:aws:iam::126450723953:role/OrganizationAccountAccessRole"
  }
}

data "terraform_remote_state" "testing" {
  backend = "s3"
  provider = "aws.testing"

  config {
    bucket = "${var.namespace}-testing-terraform-state"
    key    = "account-settings/terraform.tfstate"
  }
}
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
should I be able to do something like this?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
...some context
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I am in our "root" aws account and want to read the tfstate from a child account
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
I don't see why not
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
this wouldn't work if you have the access
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Trick question:


Error: data.terraform_remote_state.testing: Provider doesn't support data source: terraform_remote_state
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
sorry 😃
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so i think there's something subtle i don't understand....
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
ah I do it differently yes, but you won't like what I do
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
might help for perspective though
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
One administrative account, here default role ( before switching to assume role ) has access to the state bucket and kms
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
inside the same state bucket you then have different environments and stacks ( yep .. )
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
then in say 'provider.tf' the provider does an assumerole into the testing/staging/production account
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
where it does it's operations
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
is that more or less clear ?
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
but can't you just fix it on s3 access level ?
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago(edited)
@Erik Osterman (Cloud Posse) doesn't it accept role_arn inside the config block?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
ohhhhhhh right
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, that makes things easier for sure
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yes that's clear - i forget you mentioned that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
....still holding out from going down that path 😃 but maybe we need to consider it some day
loren
lorenalmost 8 years ago
i think the error message is trying to say that the the data source terraform_remote_state does not support the provider argument?
loren
lorenalmost 8 years ago
that data source does some odd stuff internally with the aws credential/provider to access the state file
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
so does it work with role_arn in the terraform_remote_state config {} ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
got it working!!
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

data "terraform_remote_state" "testing" {
  backend = "s3"
  config {
    role_arn = "arn:aws:iam::126450723953:role/OrganizationAccountAccessRole"
    bucket = "${var.namespace}-testing-terraform-state"
    key    = "account-dns/terraform.tfstate"
  }
}

output "testing_name_servers" {
  value = "${data.terraform_remote_state.testing.name_servers}"
}

Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so I didn't need to specify any aliases
loren
lorenalmost 8 years ago
beauty
loren
lorenalmost 8 years ago(edited)
yeah, that's what i saw in the code, that state does the credential setup itself
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the key was to add the role_arn to the config section.
loren
lorenalmost 8 years ago
makes sense now that you have it working
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
yea, even easier than I thought it would be
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
can't believe i've put it off for this long
loren
lorenalmost 8 years ago
kinda related, i saw this comment earlier today, which i can't believe works... https://github.com/terraform-providers/terraform-provider-aws/issues/571#issuecomment-448372889
loren
lorenalmost 8 years ago

provider "aws" {
  ...
}

resource "aws_organizations_account" "subaccount" {
  ...
  
  // More about this below
  provisioner "local-exec" {
    command = "sleep 120"
  }
}

locals {
   role_arn = "arn:aws:iam::${ aws_organizations_account.subaccount.id }:role/OrganizationsAccountAccessRole"
}

provider "aws" {
  alias = "subaccount"

  assume_role {
    role_arn = "${local.role_arn}"
  }
}

resource "aws_dynamodb_table" "lock_table" {
  provider  = "aws.subaccount"
  name      = "terraform-lock-table"
  ...
}
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
haha, check this out
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

data "terraform_remote_state" "root" {
  backend = "s3"
  config {
    bucket = "${var.namespace}-root-terraform-state"
    key    = "accounts/terraform.tfstate"
  }
}


data "terraform_remote_state" "testing" {
  backend = "s3"
  config {
    role_arn = "${data.terraform_remote_state.root.testing_organization_account_access_role}"
    bucket = "${var.namespace}-testing-terraform-state"
    key    = "account-dns/terraform.tfstate"
  }
}

locals {
  testing_name_servers = "${data.terraform_remote_state.testing.name_servers}"
}

resource "aws_route53_record" "testing_dns_zone_ns" {
#  count   = "${signum(length(local.testing_name_servers))}"
  zone_id = "${aws_route53_zone.parent_dns_zone.zone_id}"
  name    = "testing"
  type    = "NS"
  ttl     = "30"
  records = ["${local.testing_name_servers}"]
}

output "testing_name_servers" {
  value = "${local.testing_name_servers}"
}

Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
getting the organization account access role for a subaccount from the state of one module in our root account
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
then using that to assume role into the subaccount and read the state from a module in that account
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
oh, and it even works with that count enabled
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
and no "count of cannot be computed" bs
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
oh nice one 🙂 doing the same, but not so automated 🙂
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago(edited)
this or brute forcing the creation of a new domain until the ns-servers match 🙂
johncblandii
johncblandiialmost 8 years ago(edited)
@Erik Osterman (Cloud Posse) @Andriy Knysh (Cloud Posse) any reason why this uses the AZ as the count as opposed to the subnets?


resource "aws_efs_mount_target" "default" {
  count           = "${length(var.availability_zones)}"
  file_system_id  = "${aws_efs_file_system.default.id}"
  subnet_id       = "${element(var.subnets, count.index)}"
  security_groups = ["${aws_security_group.default.id}"]
}


https://github.com/cloudposse/terraform-aws-efs/blob/master/main.tf#L18-L23
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I think the rule is you only need one per az and not one per subnet
johncblandii
johncblandiialmost 8 years ago
but if it is per az and there are public/private subnets, will the one’s left out not get access?
johncblandii
johncblandiialmost 8 years ago
when I used the private subnets, my eks cluster couldn’t talk to efs
johncblandii
johncblandiialmost 8 years ago
well…it still can’t use it. lol. but using public got beyond the “can’t connect” phase
erik
erikalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I don’t recall the details off the top of my head
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Just remembered this requirement for some reaon...
johncblandii
johncblandiialmost 8 years ago
ha…just found it. 🙂
johncblandii
johncblandiialmost 8 years ago(edited)

You can create one mount target in each Availability Zone.
johncblandii
johncblandiialmost 8 years ago
interesting.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Hrmmm haven’t tried to use it yet with EKS
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
It’s been a LONG time since we touched EFS for client engagements. Not that there is anything wrong just memory of it fading.
johncblandii
johncblandiialmost 8 years ago
All good. I’ve never used it so it is new to me.
johncblandii
johncblandiialmost 8 years ago
trying to get my nfs setup on the cluster
johncblandii
johncblandiialmost 8 years ago
Dec has been a month of “here’s something new…get it in production” 😄
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@johncblandii the assumption was one subnet per AZ. Actually it’s two subnets per AZ (private and public), but you use either private or public to place the EFS
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
it does not cover all possible use cases I agree
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and you have to provide the same number of subnets as you have AZs
antonbabenko
antonbabenkoalmost 8 years ago(edited)
Did anyone use blue-green deployments with ECS&CodeDeploy? I am trying, but it is not so straightforward, it is more greenfield area then I wanted it to be… In case you will want to make it - https://gist.github.com/antonbabenko/632b54e8e488b9f48d016238792a9193
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
antonbabenko
antonbabenkoalmost 8 years ago
rohit
rohitalmost 8 years ago
I am facing the same issue that is mentioned here https://github.com/hashicorp/terraform/issues/13012
rohit
rohitalmost 8 years ago
any ideas why ?
rohit
rohitalmost 8 years ago
I am facing weird issues with aws_launch_template resource where when we work with the same code on mac vs windows
rohit
rohitalmost 8 years ago
everytime my teammate or i run terraform plan it shows that there is a change in the launch template
rohit
rohitalmost 8 years ago(edited)
and i believe it is because of
  user_data = "${base64encode(data.template_file.user-data.rendered)}"
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
if you are using file for template (not inline), the path will be different on diff systems
rohit
rohitalmost 8 years ago
is there a way to fix/avoid this issue?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
but we did not test it on Windows, so don’t know if it will behave differently
rohit
rohitalmost 8 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
that’s why it’s better to use containers for that (geodesic is a good example)
rohit
rohitalmost 8 years ago
data "template_file" "user-data" {
  template = "${file("${path.cwd}/modules/compute/frontend/user-data.sh.tpl")}"

  vars = {
    app_env               = "${terraform.workspace}"
  }
}
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) above is how we use i am currently using remplate_file
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
maybe try path.module and see what happens
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
also, you sure that the template files on mac and windows are 100% identical? (e.g. line breaks on windows differ from mac)
rohit
rohitalmost 8 years ago
yeah line breaks differ but we are running the same code
rohit
rohitalmost 8 years ago
i am not sure about the settings
rohit
rohitalmost 8 years ago
Different question, is it currently possible to launch an ec2 instance using launch template resource but not in an autoscaling group ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
launch template is just a metadata with diff params (stored somewhere in some AWS database). Autoscaling is a service that maintains the required number of running instances
rohit
rohitalmost 8 years ago
i mean using terraform
rohit
rohitalmost 8 years ago
i did not find an option to provide launch template id to aws_instance resource
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
many attributes are the same as in launch template
rohit
rohitalmost 8 years ago
yes lot of the attributes are same
rohit
rohitalmost 8 years ago
i did not find any resources online to do this
rohit
rohitalmost 8 years ago
I am thinking of creating a feature request on github
rohit
rohitalmost 8 years ago
Looks like there is already one
loren
lorenalmost 8 years ago
got a pr already too, a bit long in the tooth, maybe add a thumbs up in case they sort on reactions... https://github.com/terraform-providers/terraform-provider-aws/pull/4543
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
still pending from May 15
rbadillo
rbadilloalmost 8 years ago
Team, does anybody know if it is possible to escape $ in template_file ?
rbadillo
rbadilloalmost 8 years ago
My template file has this:


$(kubectl config current-context)
rbadillo
rbadilloalmost 8 years ago
by not escaping the $ it results in an empty file because somehow it is being evaluated
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
$$
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
rbadillo
rbadilloalmost 8 years ago
it doesn’t work
rbadillo
rbadilloalmost 8 years ago
it escapes the $ if it is follow by {
rbadillo
rbadilloalmost 8 years ago
but not $()
rbadillo
rbadilloalmost 8 years ago
the double $$ is to escape interpolation no to escape the dollar sign
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we did something like this before: template = "${replace(var.storage_account_container_readonly_template, "$$$$", "$")}"
rbadillo
rbadilloalmost 8 years ago
yep, looks like that’s the workaround for now
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
I've documented our versioning strategy so it's more clear for others.
mrwacky
mrwackyalmost 8 years ago(edited)
https://www.terraform.io/docs/providers/aws/r/route53_zone_association.html
NOTE: Unless explicit association ordering is required (e.g. a separate cross-account association authorization), usage of this resource is not recommended. Use the vpc configuration blocks available within the aws_route53_zone resource instead.


Yes, but when I create the zone, all the other VPCs might not yet exist
mrwacky
mrwackyalmost 8 years ago
so I shall not take your advice @hashicorp
rohit
rohitalmost 8 years ago
@Andriy Knysh (Cloud Posse) so after playing a bit i ended up with
  template = "${file("${path.module}/user-data.sh.tpl")}"
rohit
rohitalmost 8 years ago(edited)
that worked but when i ran terraform plan it says there is an update to the launch template 😂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
@rohit does the TF output show what part it wants to update?
jeffrey
jeffreyalmost 8 years ago(edited)
has anyone come across cloudwatch alarms created through terraform not being displayed in the elastic beanstalk console, but being correctly displayed in the cloudwatch console? i've checked all configurations to make sure they match up, including the dimensions; however any cloudwatch alarm created through the GUI still displays in both the EB console and cloudwatch console.

the only difference between the 2 are specifying the actions to be taken when the threshold is met
Jan
Janalmost 8 years ago
Have we considered using terraform-landscape yet? https://github.com/coinbase/terraform-landscape
erik
erikalmost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
trying not to depend on ruby
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
it installs the world
Jan
Janalmost 8 years ago
Fair point
Shane
Shanealmost 8 years ago
Someone want to go rewrite landscape in golang 😉
davidvasandani
davidvasandanialmost 8 years ago(edited)
diff renderer changes are coming with 0.12
https://github.com/hashicorp/terraform/issues/15180#issuecomment-435241641

but 0.12 still leaves something to be desired:

  # aws_iam_role_policy.policy will be created
  + resource "aws_iam_role_policy" "policy" {
      + id     = (known after apply)
      + name   = "tf-example-policy"
      + policy = "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Action\": [\n        \"kinesis:PutRecord\",\n        \"kinesis:PutRecords\"\n      ],\n      \"Resource\": [\n        \"*\"\n      ],\n      \"Effect\": \"Allow\"\n    }\n  ]\n}\n"
      + role   = (known after apply)
    }


vs 0.11 w/ landscape

+ aws_iam_role_policy.policy
    id:       "<computed>"
    name:     "tf-example-policy"
    policy:   {
                "Statement": [
                  {
                    "Action": [
                      "kinesis:PutRecord",
                      "kinesis:PutRecords"
                    ],
                    "Effect": "Allow",
                    "Resource": [
                      "*"
                    ]
                  }
                ],
                "Version": "2012-10-17"
              }
    role:     "${aws_iam_role.role.id}"
rohit
rohitalmost 8 years ago
Is it possible to apply selected changes from terraform plan ?
Shane
Shanealmost 8 years ago
No, you must do a targeted terraform plan
Shane
Shanealmost 8 years ago
At least I'm about 90% certain
rohit
rohitalmost 8 years ago
how does that work ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so for example, base on @davidvasandani text grab above, we could run
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

terraform apply -target aws_iam_role_policy.policy
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
to only apply that change
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the same is true for modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
or similarly
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago

terraform plan -out planfile
terraform apply planfile
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
this will only apply the changes that are in the planfile
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
and plan supports -target as well
rohit
rohitalmost 8 years ago
that's awesome
rohit
rohitalmost 8 years ago
i am not aware of all the capabilities that terraform provides
rohit
rohitalmost 8 years ago
so whenever i need something, i go and check if terraform that specific feature
lvh
lvhalmost 8 years ago
hey; I got bit by https://github.com/cloudposse/terraform-aws-tfstate-backend/commit/86b17f16e0c95244e87c859c18e28afa4deb1783

in particular because terraform-aws-tfstate-backend doesn't have an "environment", we synthesized it:


module "terraform_state_backend" {
  source      = "git::<https://github.com/cloudposse/terraform-aws-tfstate-backend.git?ref=master>"
  # The terraform_state_backend module, unlike other CloudPosse modules, does
  # not have an "environment" argument, so we synthesize it.
  namespace   = "${var.namespace}-${var.client_codename}"
  # environment = ""
  stage       = "${var.stage}"
  name        = "${var.name}"
  region      = "${var.aws_region}"
}
lvh
lvhalmost 8 years ago
the new version deletes te dashes
lvh
lvhalmost 8 years ago
there doesn't seem to be an obvious workaround for that
lvh
lvhalmost 8 years ago
unless the new thing takes an environment? let's see
lvh
lvhalmost 8 years ago
(I have other code that imports state so it cares p deeply about what the exact bucket name is -- and because it's importing state to bootstrap, it can't just ask the current state what the bucket name is)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
sorry @lvh, we messed it up
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
we’ll fix it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
can you pin to the previous release for now?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
(don’t use master)
lvh
lvhalmost 8 years ago
sure no problem
lvh
lvhalmost 8 years ago(edited)
I was able to fix the naming issue by setitng the environment var though
lvh
lvhalmost 8 years ago
still can't reach the module outputs? but not sure that has anything to do with the change 🙂
lvh
lvhalmost 8 years ago

    {
      "path": [
        "root",
        "terraform_state_backend"
      ],
      "outputs": {},
      "resources": {},
      "depends_on": []
    },


... weirdly
lvh
lvhalmost 8 years ago
nuking the env and starting over fixed it, oh well 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
don’t use master 🙂
lvh
lvhalmost 8 years ago
okiedokie 🙂 this doesn't really stirke me as a bug, but I'll pin a tag anyway
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
---
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
PSA don’t use boolean types in terraform.

https://github.com/cloudposse/docs/issues/342
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
Question about https://github.com/cloudposse/terraform-aws-jenkins. After setup, I navigated to the URL and saw the Elastic Beanstalk splash page - "Congratulations!
Your Docker Container is now running in Elastic Beanstalk on your own dedicated environment in the AWS Cloud." Am I doing something wrong here? Or is this a current bug? Any ideas?
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
Love the terraform modules you guys put out, by the way 🙂
Jan
Janalmost 8 years ago
Maybe in the aws console go look at the created elb and see if it's target is set and shows as healthy
Jan
Janalmost 8 years ago
I have not run that module myself though
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
It shows as healthy. I did see that the Jenkins container exposes port 8080 but the ALB listener points to port 80. Do you think that’s the issue?
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
Not sure if that’s just an elastic beanstalk thing. Haven’t worked with it before
Steven
Stevenalmost 8 years ago
It is normal for the container port and alb port to be different
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
figured out the issue.
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
i set "null" to the github_oauth_token parameter instead of actually leaving it blank
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Thanks for reporting back! If you wouldn’t mind - maybe a good idea to open the issue against the repo in case others make the same mistake. 😃
Kinnaird McQuade
Kinnaird McQuadealmost 8 years ago
sure thing. let me figure out the solution first and then i'll happily open up an issue 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
TIL:
erik
erikalmost 8 years ago
Gabe
Gabealmost 8 years ago
@mrwacky ^^
mrwacky
mrwackyalmost 8 years ago
fancy
Sanjay
Sanjayalmost 8 years ago
Question regarding https://github.com/cloudposse/terraform-aws-datadog-integration .. Once I run the code should I go to datadog console and fill the AWS integration form again to complete the integration install ? ExternalID is changing every time I open the AWS integration form under my datadog account
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Sanjay - Its been a while since we set that up, so I cannot recall seeing that
Maarten van der Hoef
Maarten van der Hoefalmost 8 years ago
@Sanjay the Datadog page is confusing.
From what I remember, first open the page, to get the external ID. Then run Terraform, then back to the Datadog page, find a way to Save. I made the mistake often to get a new id instead of just saving it.
Sanjay
Sanjayalmost 8 years ago(edited)
Thanks @Maarten van der Hoef and @Erik Osterman (Cloud Posse).. Yes it is a 3 step process 1) Get external ID 2) Run TF code for integration which creates IAM role 3) Go back to Datadog console and input IAM role and AccountID to complete the integration. Was wondering if there is a way to do everything using TF code rather than using console ?
Sanjay
Sanjayalmost 8 years ago
Also one other question I had is about https://github.com/cloudposse/terraform-datadog-monitor . Do we need to run integration first or can we just run the monitors code independently without installing AWS integration.. Here it is using API KEY and APP KEY
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
@Sanjay from what I recall they are disjoint
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
so the terraform-datadog-monitors module sets up the alerts, but the metrics themselves come from the datadog agents - of which are not covered by any of our modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
the terraform-aws-datadog-integration enables datadog to scrape metrics from cloudwatch/rds, but I don't think the terraform-datadog-monitor module is setup to work with it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
We've released the first version of our "reference architectures" cold start automation process.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
This will get you setup with #geodesic starting with a fresh AWS account.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago
(just used this to provision the account infra for one of our customer)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 8 years ago
❤️
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 8 years ago(edited)
@Jan @Mike Crowe @Dombo @Dave Yu @Rohit Verma @Rohit Verma @tamsky ☝️
Mike Crowe
Mike Crowealmost 8 years ago
@Mike Crowe has joined the channel
Jan
Janalmost 8 years ago
Brilliant work mate!