#terraform - April 2019

ldlework
ldleworkover 7 years ago
Today I tried the fixes that I thought were at the root of my CodePipeline/CodeBuild IAM issues, namely pulling out the ECR module so that it could be created before the pipeline was, but this didn't actually solve the issue. Back at the same spot I was before.
ldlework
ldleworkover 7 years ago
I'm really not sure why the IAM logic inside of the CloudPosse ecs-codepipeline module is failing for me now.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
what’s the error?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
this is a working example of using ECS with CodePipeline https://github.com/cloudposse/terraform-aws-ecs-atlantis
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
i feel that you are missing the default backend app https://github.com/cloudposse/terraform-root-modules/blob/master/aws/ecs/default-backend.tf, that is created and deployed to the cluster before the CodePipeline starts building your app
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@ldlework ^
ldlework
ldleworkover 7 years ago
I'm gonna think about all that
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) I've been going off this, https://github.com/cloudposse/terraform-aws-ecs-alb-service-task
ldlework
ldleworkover 7 years ago
And since I need a version that is not exposed by the ALB I have tried to edit it a bit
ldlework
ldleworkover 7 years ago
But now I am just trying to call it directly https://gist.github.com/dustinlacewell/a9cbe46d2ace7b71e2973ffb32531121 and Terraform is complaining:

* module.backend.module.service.aws_ecs_service.ignore_changes_task_definition: 1 error(s) occurred:
* aws_ecs_service.ignore_changes_task_definition: InvalidParameterException: Unable to assume role and validate the specified targetGroupArn. Please verify that the ECS service role being passed has the proper permissions.
ldlework
ldleworkover 7 years ago
oh
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
remove what you feel you don’t need later
ldlework
ldleworkover 7 years ago
I'm so screwed 😞
ldlework
ldleworkover 7 years ago
this is just not working
ldlework
ldleworkover 7 years ago
I guess I should produce a minimal example
ldlework
ldleworkover 7 years ago
What's a cloudposse module that uses the ecs-codepipeline module?
ldlework
ldleworkover 7 years ago
There's one which uses the alb, ecr registry, container definition, the ecs task with alb, codepipeline, autoscaling, and cloudwatch in an example
ldlework
ldleworkover 7 years ago
but I can't find it now
ldlework
ldleworkover 7 years ago
Race condition is not something I thought I would have to face down with Terraform
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
https://github.com/cloudposse/terraform-aws-ecs-web-app uses CodePipeline and ECR to deploy a web app to ECS
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) Yeah that's the one. I've basically tried to create a version of terraform-aws-ecs-web-app that does not expose the service via ALB and it has been a nightmare 😐️
ldlework
ldleworkover 7 years ago
Basically the part that really need changing is the module that it uses, terraform-aws-ecs-alb-service-task which has the ALB target groups baked in
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Hello terraformers,
Vidhi Virmani
Vidhi Virmaniover 7 years ago(edited)
I am using this eks module and recieving this error
Error: module.eks_cluster.aws_eks_cluster.this: vpc_config.0: invalid or unknown key: endpoint_private_access
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
hi @Vidhi Virmani
Vidhi Virmani
Vidhi Virmaniover 7 years ago
hi @Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
ask in #terraform-aws-modules since you are asking about terraform-aws-vpc from https://github.com/terraform-aws-modules
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) I narrowed it down. Check this out https://gist.github.com/dustinlacewell/0b049b6c7e9699362bf9a4a14cb11469#file-main-tf-L43 When I use the official CloudPosse task module, it works - no race condition. However, when I use my own module I get the race condition with the IAM role and the CodePipeline not being able to execute the CodeBuild step. But my modules is *literally a clone of the cloudposse module with no changes*
ldlework
ldleworkover 7 years ago
What the actual?!
ldlework
ldleworkover 7 years ago
Simply changing the source = line there causes the issue or not. How is this possible?!
ldlework
ldleworkover 7 years ago
Just as a reminder the error is:

Error calling startBuild: User: arn:aws:sts::607643753933:assumed-role/us-west-1-qa-backend-worker-codepipeline-assume/1554183144481 is not authorized to perform: codebuild:StartBuild on resource: arn:aws:codebuild:us-west-1:607643753933:project/us-west-1-qa-backend-worker-build (Service: AWSCodeBuild; Status Code: 400; Error Code: AccessDeniedException;
ldlework
ldleworkover 7 years ago
If I simply rerun the CodePipeline it runs successfully because the race condition is over.
ldlework
ldleworkover 7 years ago
The gist is basically the aws-ecs-web-app code with very little changes at all.
ldlework
ldleworkover 7 years ago
Minus the webscaling, and alerts
ldlework
ldleworkover 7 years ago
oh god what if the autoscaling and alerts somehow affect the dependency ordering
ldlework
ldleworkover 7 years ago
I mean, both the autoscaling and alerts refer to the ecs-alb-task's service_name field the same way the codepipeline module does
mmuehlberger
mmuehlbergerover 7 years ago
The pipeline error should have nothing to do with the ECS related parts of the module.
ldlework
ldleworkover 7 years ago
I've wasted so many days on this lol
mmuehlberger
mmuehlbergerover 7 years ago
I used the module as is, just disabling the codepipeline part with the parameter and built codepipeline outside and still got the error.
ldlework
ldleworkover 7 years ago
When I use all the modules using git references, it all works.
ldlework
ldleworkover 7 years ago
When I clone the ecs-alb-task locally, and refer to it instead, I get the race condition
ldlework
ldleworkover 7 years ago
Always in the build step of the codepipeline, same error
mmuehlberger
mmuehlbergerover 7 years ago
Since it only occurred when first setting up the pipeline, I didn’t bother investigating, so unfortunately I don’t have a fix for you, ready.
ldlework
ldleworkover 7 years ago
Yeah it only occurs when setting up the pipeline, if you manually rerun it, it works.
mmuehlberger
mmuehlbergerover 7 years ago
It also works, when triggering the pipeline automatically from the source step.
ldlework
ldleworkover 7 years ago
Yeah
ldlework
ldleworkover 7 years ago
manual github webhook trigger or whatever
ldlework
ldleworkover 7 years ago
I'm pretty sure it is some kind of IAM race condition
ldlework
ldleworkover 7 years ago
Like Terraform is not deciding on the same dependency graph when those two lines in my gist are changed.
mmuehlberger
mmuehlbergerover 7 years ago
If I got time later today, I might have a look at it.
ldlework
ldleworkover 7 years ago
@mmuehlberger My personal goal is to just use what's in the aws-ecs-web-app but without the ALB. I have containers that run just like my web containers but are queue workers that shouldn't be exposed via ALB.
ldlework
ldleworkover 7 years ago
I thought this would be so easy
ldlework
ldleworkover 7 years ago
😛
mmuehlberger
mmuehlbergerover 7 years ago
It always looks that way and it never is. 😂
ldlework
ldleworkover 7 years ago
do you think comparing the output between the two terraform runs might be useful?
ldlework
ldleworkover 7 years ago
like something is ordered differently maybe
mmuehlberger
mmuehlbergerover 7 years ago
I think terraform got dumber. I got the error now a couple of times, but it should clearly be able to figure out the length of a static list module.chamber_database.aws_ssm_parameter.default: aws_ssm_parameter.default: value of 'count' cannot be computed.
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
Hi, i provision a EKS cluster with terraform-aws-eks-cluster/examples/complete everything work but i see that my worked nods have multiple private ip assign to them, is this normal?
Pablo Costa
Pablo Costaover 7 years ago
Yes Vucomir, It is normal. AWS do the trick of assigning secondary IP addresses to Interfaces (ENI) in order to provide native VPC IPs to pods
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
so i got 10 secondary private ip's on one mode
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
and 2 private ip's
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
but i did not deploy anything in the cluster
Pablo Costa
Pablo Costaover 7 years ago
According to the ec2 type, the aws eks reserves secondary IPs in advance
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
Thanks!
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
if i go with node ports in that case i would not need VPC ip,
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
sorry for all this question i just start with Kubernetes
Pablo Costa
Pablo Costaover 7 years ago
This article discusses the trade-offs of aws eks networking https://www.weave.works/blog/aws-and-kubernetes-networking-options-and-trade-offs-part-3
Vucomir Ianculov
Vucomir Ianculovover 7 years ago
Thanks @Pablo Costa, will check it
Pablo Costa
Pablo Costaover 7 years ago
You are welcome !!
ldlework
ldleworkover 7 years ago
@loren @Erik Osterman (Cloud Posse) @Andriy Knysh (Cloud Posse)
loren
lorenover 7 years ago
Is that better or worse than before?
ldlework
ldleworkover 7 years ago
It would fail instantly before. 🙂
ldlework
ldleworkover 7 years ago
Looks like it's going to complete successfully. Thanks so much to all three of you again.
loren
lorenover 7 years ago
:bananadance:
ldlework
ldleworkover 7 years ago
I almost wept.
ldlework
ldleworkover 7 years ago
lol
loren
lorenover 7 years ago
I kind of hate role attachments, but there isn't yet a better option
loren
lorenover 7 years ago
Trying hard to get this pr merged, which would handle the attachment right in the role resource,https://github.com/terraform-providers/terraform-provider-aws/pull/5904
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
nice @ldlework
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
so FYI, if you have similar issues and you think it’s a race condition, the fastest way to test it without modifying a bunch of modules is to use --target to provision some resources first
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) @Erik Osterman (Cloud Posse) should I submit a PR?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
please submit
ldlework
ldleworkover 7 years ago
ok
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
released 0.6.1
johncblandii
johncblandiiover 7 years ago
I was going to submit a talk, but it seems it would boil down to “Use Cloudposse modules” for the most part. 😄

https://hashiconf.hashicorp.com/#submit-a-talk
ldlework
ldleworkover 7 years ago
It's still happening...
ldlework
ldleworkover 7 years ago
sighs
ldlework
ldleworkover 7 years ago
how is that even possible
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
So maybe it’s what it says, the assumed role user does not have permissions
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Did you go to the AWS console and start the build manually?
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) If I click the "Release Change" and start the pipeline manually it works fine.
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) look at this gist which is a cleaned up log of the terraform application: https://gist.github.com/dustinlacewell/0162c8f06273fdefe5c534c3e5267fae
ldlework
ldleworkover 7 years ago
Lines prefixed with @@ show the policy attachment lines
ldlework
ldleworkover 7 years ago
Lines prefixed with !! show the pipeline and codebuild creation lines
ldlework
ldleworkover 7 years ago
It looks like everything is created in the right order?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Under which user do you login to the console manually and start the build?
ldlework
ldleworkover 7 years ago
My own user
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It could have different permissions
ldlework
ldleworkover 7 years ago
I have used the policy tester though in the past
loren
lorenover 7 years ago
i know i've seen race conditions in things like s3 bucket policies, where i modify the bucket policy but then it takes a few seconds before it is effective (based on cli tests)
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) if I kick off the build via telling github to send the webhook that should be a real test right?
ldlework
ldleworkover 7 years ago
Is there any kind of waiter hacks I can do?
loren
lorenover 7 years ago
sleep in local exec
ldlework
ldleworkover 7 years ago
Like, run this waiter locally until the policy works for the thing
ldlework
ldleworkover 7 years ago
what a tire fire
ldlework
ldleworkover 7 years ago
I wonder if Terraform has a default parallelism I can turn off
loren
lorenover 7 years ago
yes
loren
lorenover 7 years ago
-parallelism=1
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
You can also switch the role in the console and test it manually under the real user
ldlework
ldleworkover 7 years ago
Shouldn't we be able to deduce precisely which part of the terraform is responsible for this?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
If it’s a permissions issue, it’s not terraform responsibility. You can give broader permissions to the created role and apply again
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Give it admin permissions to test
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) What I meant is, the HCL responsible for setting up this permission, like identifying the bit that is supposed to give the right permission to the right role.
ldlework
ldleworkover 7 years ago
I'm not sure what IAM role or policy document etc is responsible for this particular failure...
ldlework
ldleworkover 7 years ago
And if I give it admin, will that even matter since it seems to be a race condition? It wont have admin in time.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
That’s how you test if it’s a race condition or permissions issue
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) do you know which policy is the right one?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Give all four policies an admin permission and test
loren
lorenover 7 years ago
Also try running the pipeline from the cli, in debug mode. Might capture the permission failure better
ldlework
ldleworkover 7 years ago
like this ?

  statement {
    sid = ""
    actions = ["*"]
    resources = ["*"]
    effect    = "Allow"
  }
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Yes try it
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) do I need to add the principal or will omitting it allow any service to assume it or whatever
ldlework
ldleworkover 7 years ago
* aws_iam_role.default: Error creating IAM Role us-west-1-qa-backend-codepipeline-assume: MalformedPolicyDocument: Has prohibited field Resource
ldlework
ldleworkover 7 years ago

data "aws_iam_policy_document" "assume" {
  statement {
    sid = ""
    actions = ["*"]
    resources = ["*"]
    effect    = "Allow"
  }
}
ldlework
ldleworkover 7 years ago
i'm going crazy lol
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Specify resources
ldlework
ldleworkover 7 years ago
huh, it's building on the first time
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It should. We used those modules about 125 times and never saw the issues with race conditions (not saying they can’t be introduced by TF or AWS)
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) I suspect that it has something to do with how I'm wrapping your modules in my own modules. Like for my codepipeline, I call ecs-codepipeline and the cloudposse module for ECR as an example
ldlework
ldleworkover 7 years ago
And I had to fork the ecs task module so I can remove the ALB
ldlework
ldleworkover 7 years ago
Actually, I have zero idea
ldlework
ldleworkover 7 years ago
Because why would making the role an admin work
ldlework
ldleworkover 7 years ago(edited)
it makes one want to crawl under their desk and dissapear
ldlework
ldleworkover 7 years ago
Can I ask some general IAM questions about the ecs-codepipeline module? Is it creating one IAM role but attaching multiple policies? Like is one policy, the sts:AssumeRole policy, the policy that lets the CodeBuild service assume the role we're creating?
ldlework
ldleworkover 7 years ago
and then the other policy documents that are attached describe what that user can do?
ldlework
ldleworkover 7 years ago
freaking magnets
ldlework
ldleworkover 7 years ago
how do they work?!
ldlework
ldleworkover 7 years ago
OK so I narrowed it down
ldlework
ldleworkover 7 years ago

data "aws_iam_policy_document" "codebuild" {
  statement {
    sid = ""

    actions = [
      "codebuild:*",
    ]

    resources = ["${module.build.project_id}"]
    effect    = "Allow"
  }
}
ldlework
ldleworkover 7 years ago
Changing the resources there to be "*" fixes the issue apparently.
ldlework
ldleworkover 7 years ago
Thoughts?
loren
lorenover 7 years ago
Is that project_id actually the arn? codebuild:StartBuild requires the arn...
loren
lorenover 7 years ago
arn:aws:codebuild:region-ID:account-ID:project/project-name
ldlework
ldleworkover 7 years ago
ldlework
ldleworkover 7 years ago

output "project_id" {
  description = "Project ID"
  value       = "${join("", aws_codebuild_project.default.*.id)}"
}
ldlework
ldleworkover 7 years ago
It does seem to be the ARN...
loren
lorenover 7 years ago
ldlework
ldleworkover 7 years ago
There's never any answers!!!
ldlework
ldleworkover 7 years ago
lol
ldlework
ldleworkover 7 years ago
I've redeployed a few times. It's definitely the "*" for resources on that one policy.
loren
lorenover 7 years ago
Maybe look in the account and double-check that is the actual arn of the project, and that the policy lists that same arn
ldlework
ldleworkover 7 years ago
ok
ldlework
ldleworkover 7 years ago
OK I redeployed with the original code, and it failed as expected:
ldlework
ldleworkover 7 years ago
And here is the role, and attached policy with resource shown:
ldlework
ldleworkover 7 years ago
Thoughts?
ldlework
ldleworkover 7 years ago
The ARN in the error message, and the ARN listed in the policy are the same.
ldlework
ldleworkover 7 years ago

arn:aws:codebuild:us-west-1:607643753933:project/us-west-1-qa-backend-build
ldlework
ldleworkover 7 years ago

arn:aws:codebuild:us-west-1:607643753933:project/us-west-1-qa-backend-build
loren
lorenover 7 years ago
This looks like an aws thing, not so much a terraform thing....
loren
lorenover 7 years ago
There's some permission getting used under the covers and the error message is obscuring the real error
loren
lorenover 7 years ago
Still recommend trying to run the pipeline from the cli, using a credential for that same role
ldlework
ldleworkover 7 years ago(edited)
Could it have anything to do with:
loren
lorenover 7 years ago(edited)
It's really hard to create a restrictive IAM policy that doesn't result in that message. I generally consider it a red herring
ldlework
ldleworkover 7 years ago
I see.
loren
lorenover 7 years ago(edited)
But, if you look at the codebuild IAM link I shared above, you'll see that some actions do not support resource restrictions... So for those actions, the codebuild:* permission isn't applying, because the resource attribute is not *
loren
lorenover 7 years ago
Delete, import, and some "list" actions, in particular
loren
lorenover 7 years ago
If the pipeline is, under covers, trying one of those actions, maybe list something or other, then it won't have permission
loren
lorenover 7 years ago
Which would explain why it works when you change the resource to *
ldlework
ldleworkover 7 years ago
But not why this works for everyone else who uses the CloudPosse module as-is 😂
loren
lorenover 7 years ago
😂 ¯\(ツ)/¯
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
What’s the output of this?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago

output "project_id" {
  description = "Project ID"
  value       = "${join("", aws_codebuild_project.default.*.id)}"
}
ldlework
ldleworkover 7 years ago
I just destroyed and am re-rolling so I'll let you know if a bit
ldlework
ldleworkover 7 years ago
😮
ldlework
ldleworkover 7 years ago

us-west-1-qa-backend-build
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It actually looks like not a permissions issue :) and definitely not a race condition.
ldlework
ldleworkover 7 years ago

project_id = arn:aws:codebuild:us-west-1:607643753933:project/us-west-1-qa-backend-build
project_name = us-west-1-qa-backend-build
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It just looks like wrong name
ldlework
ldleworkover 7 years ago
I'm not crazy!!!!
ldlework
ldleworkover 7 years ago
rejoyces.
ldlework
ldleworkover 7 years ago
Want a PR?
ldlework
ldleworkover 7 years ago
I'll test first actually.
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) because how does the policy end up with the right ARN as the resource?
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) ecs-codepipeline does use the project_id
ldlework
ldleworkover 7 years ago
So I think it's correct...
ldlework
ldleworkover 7 years ago
I'm hedging on @loren's explanation
loren
lorenover 7 years ago
You can extend the policy document to include a second statement for codebuild:List with a resource of
loren
lorenover 7 years ago(edited)
If that works reliably, good to go, got a viable min permissions policy
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Are you using one AWS account or many? That assume role is in the same account?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Because it has nothing to do with the permissions. When you changed the ARN of the build project (by using * but still) it worked
ldlework
ldleworkover 7 years ago
Just one account.
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) but I showed with screenshots before that the ARN that ends up in the policy is the same one mentioned in the error
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
But of course it should be the same, otherwise you would not see the error :)
ldlework
ldleworkover 7 years ago
huh?
ldlework
ldleworkover 7 years ago
The policy gives codebuild access to the ARN of the project that shows up in the error complaining the policy doesen't give it access
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
The error message was generated from the provisioned resources
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
That’s why the ARNs are the same
ldlework
ldleworkover 7 years ago
But isn't the ARNs being the same what gives the service permission to do stuff to that resource?
ldlework
ldleworkover 7 years ago
I feel like I'm missing something big here 😂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Are you using CP label module to name ALL the resources?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Check if namespace, stage and name are the same for all modules you are using
ldlework
ldleworkover 7 years ago
@Andriy Knysh (Cloud Posse) I haven't changed any of the naming inside of the ecs-codepipeline module. I pass in a namespace, stage, and name to ecs-codepipeline but don't change how it uses it.
ldlework
ldleworkover 7 years ago
Are you saying this needs to be the same across ALL resources across all CloudPosse modules in use?
ldlework
ldleworkover 7 years ago
Like when I call the container definition, the ecs-alb-task, etc?
ldlework
ldleworkover 7 years ago
(I don't want to maintain a fork of ecs-codepipeline and so haven't made any changes except the depends_on changes which were merged, and changing the resource to "*".
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
I just asked if you used the same namespace, stage and name for all resources and modules that you used in that particular project
ldlework
ldleworkover 7 years ago
No like, when I call a module, I pass in the aws_region as the namespace, the stage name as the stage, and the module name as the name
ldlework
ldleworkover 7 years ago
like I pass in "codepipeline" as the "name" to codepipeline module
ldlework
ldleworkover 7 years ago
I'll try unifying everything
ldlework
ldleworkover 7 years ago
As far as I can see everything is already unified. I was wrong about changing the name parameter. I pass the top-level var.name all the way down. So everything is getting "backend" as the var.name
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Share your complete code, we’ll take a look. Maybe something changed in TF or AWS, or maybe it’s a user/permissions issue (not the permissions from the module, but rather how it’s used)
ldlework
ldleworkover 7 years ago
ldlework
ldleworkover 7 years ago
Let me know if you want me to add something else
ldlework
ldleworkover 7 years ago(edited)
qa/main.tf calls fargate-alb-task/main.tf calls my ecs-codepipeline/main.tf calls CloudPosse ecs-codepipeline
ldlework
ldleworkover 7 years ago
It is basically the ecs-alb-web-app module, with each layer, vpc, aurora, elasticache, alb, ecs, and each of the ecs services implemented as a layer module
ldlework
ldleworkover 7 years ago
each layer module usually calls out to CloudPosse modules - like my ecs-codepipeline module calls both the CloudPosse ECR and CodePipeline modules
ldlework
ldleworkover 7 years ago(edited)
stage -> layer -> component -> cloudposse/resources
ldlework
ldleworkover 7 years ago
so the qa stage has a layer called "backend" which is an invocation of the "fargate-alb-service", which calls a number of my own component modules like "container" "ecs-alb-service" and "codepipeline". My component modules usually compose a few cloudposse modules and resources.
ldlework
ldleworkover 7 years ago
I should rename my codepipeline module to something like cicd or pipeline
ldlework
ldleworkover 7 years ago
I guess one thing I wonder is whether you guys would accept a patch that allowed you to override the resource value?
ldlework
ldleworkover 7 years ago
This would allow me to move on without having to fork codepipeline for that
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
So we’ll take a look a little bit later
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
The problem with using * for resources is a security hole
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It gives permissions for all codebuild resources
ldlework
ldleworkover 7 years ago
Yeah I understand. No one would have to use that option to override the resource as "*" though.
ldlework
ldleworkover 7 years ago
Juan Cruz Diaz
Juan Cruz Diazover 7 years ago
Hello there! Where i can find some references to cloudflare terraform modules
tallu
talluover 7 years ago
how can I convert
> replace(replace(replace(replace("m1.xlarge,c4.xlarge,c3.xlarge,c5.xlarge,t2.xlarge,r3.xlarge","/^/","{ \"InstanceType\" :\""),"/,/","\"},"),"/$/","\"}"),"/,/",",{\"InstanceType\": \"")
{ "InstanceType" :"m1.xlarge"},{"InstanceType": "c4.xlarge"},{"InstanceType": "c3.xlarge"},{"InstanceType": "c5.xlarge"},{"InstanceType": "t2.xlarge"},{"InstanceType": "r3.xlarge"}

into
[{ "InstanceType" :"m1.xlarge"},{"InstanceType": "c4.xlarge"},{"InstanceType": "c3.xlarge"},{"InstanceType": "c5.xlarge"},{"InstanceType": "t2.xlarge"},{"InstanceType": "r3.xlarge"}]
and still be able to use it in Cloudformation looks like the } is the issue with the CF template
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@tallu you want to convert the string to a list, or just replace the chars?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
I'm going to hang out in this zoom for a little bit in case anyone has any questions.
tallu
talluover 7 years ago(edited)
I want to convert string or maybe list "m1.xlarge,c4.xlarge,c3.xlarge,c5.xlarge,t2.xlarge,r3.xlarge" to json
[{ "InstanceType" :"m1.xlarge"},{"InstanceType": "c4.xlarge"},{"InstanceType": "c3.xlarge"},{"InstanceType": "c5.xlarge"},{"InstanceType": "t2.xlarge"},{"InstanceType": "r3.xlarge"}]
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
that's quite easy. use smething like this
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
format("[%s]", join(",", formatlist("{\"InstanceType\": \"%s\"}", split(var.list)))
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
i haven't tested that and might have bungled something small
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
but if you look at the interpolations for terraform, you'll see where i'm coming from
tallu
talluover 7 years ago
thanks let me give it a shot
tallu
talluover 7 years ago(edited)
the output seems to be working but something in that is making Cloudformation fail
Nevermind it seems something else
ldlework
ldleworkover 7 years ago
Does anyone have any information on how to establish a registered domain name (say on GoDaddy) with AWS via Terraform?
ldlework
ldleworkover 7 years ago
I've never done Route53 anything before.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@ldlework that module is used to create a zone with delegation
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
ldlework
ldleworkover 7 years ago
What about the second-level-domain, like "example.com" how do I initially set that up with Route53? Or can I do that with the cluster-zone module?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
then get the name servers from the output and update NS records in GoDaddy
ldlework
ldleworkover 7 years ago
What if I want to use AWS for the DNS?
ldlework
ldleworkover 7 years ago
Like I'm trying to migrate a domain from GoDaddy to completely managed by AWS with Terraform as much as possible.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
the root name servers are where you buy the domain itself
ldlework
ldleworkover 7 years ago
it can be transfered right?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
so if you buy it on GoDaddy, you can’t use the root NS on AWS
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
if you buy the domain in Route53, then yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
transfer too
ldlework
ldleworkover 7 years ago
OK, so that step has to be manual. But once the domain is "owned" by AWS, then I can create zones and stuff with Terraform.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Tim Malone
Tim Maloneover 7 years ago
Not sure if this is what was being asked, but, 2 things:
- you can manage the DNS in a different place to where you buy the domain, if you want
- Terraform can’t manage Route53 domain registrations/management; just the DNS side of things
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you can create zones and records with TF even if you have not transferred the domain yet
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
it just will not be visible on the internet
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
I don't know about GoDaddy, but many Registrars let you use different Nameservers including Route53.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
(if you buy the domain on GoDaddy, you have to update the name servers there to point to the AWS NS)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
(unless you transfer it to Route53)
ldlework
ldleworkover 7 years ago
OK so it seems like just having the domain's DNS point to route53 for now is fine and I'll be able to build out the infrastructure just fine with that setup
ldlework
ldleworkover 7 years ago
thank you
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
yes, create the zone, get its name servers, update them in GoDaddy, then you can create records in the Route53 zone
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
also, you will be able to request SSL certs with domain validation only after you update the NS records in GoDaddy
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
(in other words, ROOT NS records can be updated in the DNS system only by the entity that sold you the domain, or you transfer it to)
ldlework
ldleworkover 7 years ago
We have a single AWS account, and I'm going to be running QA in us-west-1 and Prod in us-east-1 (for the foreseeable future) does it make sense to have some Terraform that is not part of our "environment deployments" that sets up the zone for the dns in a "global-y" way sort of how I'm doing for the initial terraform state?
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
@ldlework If you still need to setup QA, I would personally opt for a new account and sticking to the same region.
ldlework
ldleworkover 7 years ago
I asked and was denied.
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
Ugh, why, can I ask ?
ldlework
ldleworkover 7 years ago
We're a poor startup, far behind schedule, lead by a young inexperienced slightly petulant guy who makes random decisions that can't be rationally accounted for.
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
Having seperate accounts is actually part of the AWS Well architected framework
ldlework
ldleworkover 7 years ago
Trust me, its not even close to the most mind-bending thing I have to deal with.
ldlework
ldleworkover 7 years ago
I agree, I'm fully on board.
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
and does not cost more, actually less if you have support on one account and no support on the qa account ( not sure if this still is the case)
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
good luck with that 🙂 anyway, what i do in certain situations is to give prod and dev their own hosted zone
ldlework
ldleworkover 7 years ago
The point is you don't have to convince me, I'm already convinced. I gave many more reasons too. 🙂
ldlework
ldleworkover 7 years ago
I see.
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
dev.domain.com prod.domain.com or more obfusicated, and have terraform setups to maintain those hosted zones
ldlework
ldleworkover 7 years ago
what about "domain.com"
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
clearly for domain.com and www.domain.com you would need to create an alias to the existing record in prod.domain.com
ldlework
ldleworkover 7 years ago
so I can't use "domain.com" instead of "prod.domain.com" ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you can do this (fewer reasons to convince the boss 🙂 :
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
1. <http://domain.com|domain.com> is the vanity domain, the brand (the business owns it)
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
@ldlework you can , you can have multiple zones in your route53
Maarten van der Hoef
Maarten van der Hoefover 7 years ago(edited)
one for domain.com ( with IN NS records delegating sub domains to different authorative nameservers AKA the other hosted zones you are going to make )
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
2. You buy <http://domain.io|domain.io> in Route53 and use it for all service discovery
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
3. Create <http://prod.domain.io|prod.domain.io>, <http://staging.domain.io|staging.domain.io>, <http://dev.domain.io|dev.domain.io> subdomains for your environments
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
4. Then in <http://domain.com|domain.com> zone, add CNAME to <http://prod.domain.io|prod.domain.io> (this could even be on GoDaddy if the business does not want to move or update it)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
^ you separate the business-related stuff from the infra stuff
ldlework
ldleworkover 7 years ago
It makes a lot of sense.
ldlework
ldleworkover 7 years ago
So for a given domain, I have to extract the nameservers from something in Route53 and add them to GoDaddy. Do I extract the nameservers from the zone's that are created with Terraform? Do I have to do this for each zone or just one?
ldlework
ldleworkover 7 years ago
(You can tell how I've never done any of this before)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
just for one “root” zone (domain.com)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
get its name servers and update in GoDaddy
ldlework
ldleworkover 7 years ago
You don't think I should manage this indepdendently from environments?
ldlework
ldleworkover 7 years ago
Well you do, you said get two domains, but I only have one for now.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you have two cases here: 1) update the vanity domain NS in GoDaddy and then create all subdomains in the same Route53 zone
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
2) do service discovery domain and subdomains, and then add CNAME to the vanity domain
ldlework
ldleworkover 7 years ago
Can't I add one root zone with some side-Terraform for "domain.com", get the NS from it, add those to GoDaddy. Then in my deployments create a per-deployment zone for "prod.domain.com" "dev.domain.com" etc, which point to that environment's resources, using remote data resource to get a referencce to the root zone id or whatever? Then I could have some kind of CNAME in the root zone pointing at the "prod.domain.com" record in the prod-specific zone?
ldlework
ldleworkover 7 years ago
So that "domain.com" resolves to "prod.domain.com"?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
that’s what we do
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
it could be in one AWS account, or in multiple (in which case we do DNS zone delegation, which is to say we add NS records from <http://prod.domain.io|prod.domain.io> to the root zone <http://domain.io|domain.io> NS )
ldlework
ldleworkover 7 years ago
OK cool, so first step, write some side-terraform to setup the root zone for "domain.com" and get that configured with GoDaddy. Then I can update my deployment HCL, to get a reference to the root zone, to add a deployment specific zone on a subdomain. I guess I'll have to hand-add the record pointing from "domain.com" to "prod.domain.com" or something.
ldlework
ldleworkover 7 years ago
Since it seems like a circular reference kinda.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
if you with CNAME, those should be diff domains
ldlework
ldleworkover 7 years ago
OK so I'll need some other kind of record in the root zone then?
ldlework
ldleworkover 7 years ago
Or are you saying with a single domain, I should only have one zone, but each deployment adds records to it?
ldlework
ldleworkover 7 years ago
argh, I should probably just start and a lot will be clearer on the way maybe 🤔
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
see the use-cases above ^
ldlework
ldleworkover 7 years ago
OK
Maarten van der Hoef
Maarten van der Hoefover 7 years ago
( one side note, for the apex record, not www. , just domain.com CNAME's don't exist, but aws has ALIAS A records which achieve the same thing )
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago

1) update the vanity domain NS in GoDaddy and then create all subdomains in the same Route53 zone 2) do service discovery domain and subdomains, and then add CNAME to the vanity domain
ldlework
ldleworkover 7 years ago
So I guess I have to go with 1)
ldlework
ldleworkover 7 years ago
Which means just one zone...
ldlework
ldleworkover 7 years ago
OK I'll give it a go!
ldlework
ldleworkover 7 years ago
Oh you guys were saying that I can use multiple zones, one root zone, multiple staging zones, if I add NS records to the root zone pointing to the staging zones.
ldlework
ldleworkover 7 years ago
right?
ldlework
ldleworkover 7 years ago
Which is what I'll want because I'll need things like "db.dev.domain.com" so I do need per-stage zones, not just per-stage records in the root zone.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you can use a separate zone per environment
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
add its name servers records to the root zone NS for the corresponding sub-domain
ldlework
ldleworkover 7 years ago
excellent
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
we already had a similar discussion with all the examples here https://sweetops.slack.com/archives/CB6GHNLG0/p1552667297261900
ldlework
ldleworkover 7 years ago

 aws_route53_zone.root: error deleting Route53 Hosted Zone (Z1I50I6TDQ378M): HostedZoneNotEmpty
ldlework
ldleworkover 7 years ago
oh god
ldlework
ldleworkover 7 years ago
first with s3 buckets, now zones
loren
lorenover 7 years ago
AWS, and by extension terraform, protecting you from yourself 😋
keen
keenover 7 years ago
yeah deleting a zone is definitely something you almost never do outside of testing... 😉
ldlework
ldleworkover 7 years ago
How does one install a third party provider from git?
ldlework
ldleworkover 7 years ago
Without manunally cloning it, etc
ldlework
ldleworkover 7 years ago
oh you can't
loren
lorenover 7 years ago
If the third party provider publishes packages for your platform, then you can download that and place it in the same directory as your terraform binary
loren
lorenover 7 years ago
But if they don't publish packages, then you need to build it yourself
ldlework
ldleworkover 7 years ago
Yeah I was hoping that there was a mechanism to tell terraform where to get the binary package from like there is with terraform modules
loren
lorenover 7 years ago
Unfortunately not
loren
lorenover 7 years ago
Though, modules don't need to be built, so, not surprising really
ldlework
ldleworkover 7 years ago
neither do binary packages 😛
loren
lorenover 7 years ago
Well, exactly
loren
lorenover 7 years ago
Modules are not binary packages, they are just straight source code
ldlework
ldleworkover 7 years ago
I get it.
ldlework
ldleworkover 7 years ago
You guys ever get stuff like

 module.backend-worker.module.cicd.module.pipeline.module.build.aws_s3_bucket.cache_bucket: aws_s3_bucket.cache_bucket: error getting S3 Bucket Object Lock configuration: RequestError: send request failed
caused by: Get <https://us-west-1-qa-backend-worker-build-dnwylutrpukx.s3.us-west-1.amazonaws.com/?object-lock=>: dial tcp: lookup <http://us-west-1-qa-backend-worker-build-dnwylutrpukx.s3.us-west-1.amazonaws.com|us-west-1-qa-backend-worker-build-dnwylutrpukx.s3.us-west-1.amazonaws.com> on 192.168.1.1:53: no such host
ldlework
ldleworkover 7 years ago
while refreshing state
ldlework
ldleworkover 7 years ago
don't know what's oging on but I can't seem to make it through a refresh
Tim Malone
Tim Maloneover 7 years ago
yup. usually a temporary connectivity issue - just have to try again
Tim Malone
Tim Maloneover 7 years ago
(or check if there’s any status page messages on increased API error rates/latency for your service & region)
ldlework
ldleworkover 7 years ago
Right now for a given ECS service I specify the port and protocol in 3 different places: Once in the load_balancer block of the ECS service, once in the ALB listener, and once in the ALB Target Group. If I am trying to do SSL termination at the ALB, what needs the HTTPS details what needs the HTTP details?
ldlework
ldleworkover 7 years ago
I'm guessing the listener gets the HTTPS, the target group gets HTTP and the ECS service gets HTTP
ldlework
ldleworkover 7 years ago
well maybe the ECS also gets HTTPS?
ldlework
ldleworkover 7 years ago
From the aws_ecs_service docs for the container port: The port on the container to associate with the load balancer.
ldlework
ldleworkover 7 years ago
um
ldlework
ldleworkover 7 years ago
I guess this means the internal port, so HTTP
ldlework
ldleworkover 7 years ago

* module.alb.output.dns_name: 1:16: unknown variable accessed: var.domain in:

${var.stage}.${var.domain}
ldlework
ldleworkover 7 years ago
When targetting my frontend module.
ldlework
ldleworkover 7 years ago
But when I target my ALB module, it works fine?
ldlework
ldleworkover 7 years ago
Lol my root module has an output that depends on the module.alb.output.dns_name value and it outputs just fine
ldlework
ldleworkover 7 years ago
But when targetting my frontend... i get this error. It just never ends...
ldlework
ldleworkover 7 years ago
The alb module definitely has a variable named domain
ldlework
ldleworkover 7 years ago
The alb module is definitely getting passed the domain variable by the root module since I can target the alb module and apply it just fine.
ldlework
ldleworkover 7 years ago
maybe a circular dependency
ldlework
ldleworkover 7 years ago
doubt it though
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@ldlework as we already discussed (regarding the code pipeline), you can share your complete code (not just snippets) and people here could take a look and help you much faster. It’s difficult to answer anything without looking at the code
mmuehlberger
mmuehlbergerover 7 years ago(edited)
A quick question on best practices regarding Parameter Store/Chamber. We have around 40 secrets/config parameters needed for our app, that we import with chamber. How would you go about adding them to chamber. The database-related secrets, I’d add using terraform, when creating the database. Would you add the rest to TF as well, manually adding secret values later (which is what we did before), or would you use something entirely different?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
we write all secrets for the resources created with TF (e.g. RDS, Elasticache, DocumentDB) from TF when we apply. The rest of the secrets (e.g. k8s stuff, app secrets) we were writing manually (admin via geodesic). Maybe there is a better way of doing this
mmuehlberger
mmuehlbergerover 7 years ago
Okay, thanks. That’s exactly the way I’m doing it (and thanks to chamber import/export it’s actually not too bad)
ldlework
ldleworkover 7 years ago
I got everything working.
ldlework
ldleworkover 7 years ago
@oscarsullivan_old getting some Fargate services deployed behind ALB with automatic SSL challenge/termination
phanindra bolla
phanindra bollaover 7 years ago
How do i deploy AWS ASG ec2 through terraform as a blue green deployment . i am thinking about diff types of methods
1. Create a Launch template which update/ creates new ASG ,new ALB/ELB and switch the R53 domain to new
2. Create a new Launch template ,, ASG and ALB and update and target ALB to existing R53

please suggest me best way
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
#2 will save you on load balancer and looks simpler to implement
loren
lorenover 7 years ago
personally, i also use terraform to wrap a cfn template for autoscaling groups and ec2 instances
chrism
chrismover 7 years ago
Seen that post a few times; yet to try it; does it work well with the cloudformation stuff?
loren
lorenover 7 years ago(edited)
neither is a show stopper for most usage, the first is really only an annoyance when developing, the second would be nice to have but can live without it for a while
loren
lorenover 7 years ago(edited)
the biggest benefits are being able to use cfn resource signals to determine instance health (and force terraform to wait until they are really ready) and the UpdatePolicy to easily manage blue/green or rolling updates
phanindra bolla
phanindra bollaover 7 years ago
I am still not able to understand the downside of using terraform autoscaling groups for non web server clusters. Can someone please care to explain?
ldlework
ldleworkover 7 years ago
who told you there is a downside?
phanindra bolla
phanindra bollaover 7 years ago
you can see that in this post , they say using terraform Cloudformation resource is preffered over ASG resource
loren
lorenover 7 years ago
i don't read that conclusion in that quote at all
loren
lorenover 7 years ago
they simply say you can do things with an ASG in cloudformation that you cannot do in terraform because they are not exposed via an AWS API. this is simply true. doesn't make ASG's undoable in TF
loren
lorenover 7 years ago
and the two are definitely not one or the other. we use cfn in tf wherever necessary, as sometimes the tf resource just doesn't yet exist. had tf accept guard duty invites via cfn (until yesterday, when we switched to the new tf resource). probably going use cfn to create email subscriptions to sns topics shortly
Tim Malone
Tim Maloneover 7 years ago
if you’re already using Terraform it’s definitely easier to do ASGs within TF and there’s nothing inherently wrong with doing so. but if you want to do rolling deployments without doing the extra heavy lifting yourself, CF already does it really well (it’s a CF feature, not an ASG feature). the article’s proposition is ‘why not have both?’ - which can be done by managing the CF stack in TF
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Good TL;DR @Tim Malone
cabrinha
cabrinhaover 7 years ago
in the readme example, they're passing in a VPC ID as a CIDR block for a security group rule
cabrinha
cabrinhaover 7 years ago
module "db_computed_merged_sg" {
  # omitted for brevity

  computed_ingress_cidr_blocks = ["10.10.0.0/16", "${data.aws_security_group.default.id}", "${module.vpc.vpc_id}"]
  number_of_computed_ingress_cidr_blocks = 3
}
cabrinha
cabrinhaover 7 years ago
but I'm having some issue doing the same
cabrinha
cabrinhaover 7 years ago
I wonder if this is just a typo in the example
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
maybe also try #terraform-aws-modules
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
@Noah Kernis https://github.com/cloudposse/terraform-aws-ecs-web-app is an opinionated example of an web ECS app that uses other TF modules. It’s not supposed to be a generic module. You probably should fork it and add what you need, and remove what you don’t need
Noah Kernis
Noah Kernisover 7 years ago
@Andriy Knysh (Cloud Posse) thank you for an insanely quick response. Makes sense to me. Had a feeling but wanted to 2x check. Thank you again!
johncblandii
johncblandiiover 7 years ago
has anyone done ~/.terraformrc on CI to connect to TF Enterprise modules without manually writing the file to your CI server?
cabrinha
cabrinhaover 7 years ago
anyone know of a way to generate data for all cidr_blocks of all VPCs?
cabrinha
cabrinhaover 7 years ago
im trying to use data "aws_vpcs" "all" {} to get a list of all my VPC IDs, but not sure what to do after that ...
cabrinha
cabrinhaover 7 years ago(edited)
data "aws_vpc" "all" { id = "${data.aws_vpcs.all.ids}" } causes TF to crash lol
Arvind
Arvindover 7 years ago
Help !! Regarding Error
* provider.vault: failed to create limited child token: Error making API request.

URL: POST <https://vault.abc.net/v1/auth/token/create>
Code: 403. Errors:

* 1 error occurred:

* permission denied
Arvind
Arvindover 7 years ago
I am trying to get my AWS KEYS from Vault.
Arvind
Arvindover 7 years ago
provider "vault" {
}

data "vault_generic_secret" "aws_auth" {
  path = "secret/project/abc/infra_secrets"
}

provider "aws" {
  access_key = "${data.vault_generic_secret.aws_auth.data["access_key"]}"
  secret_key = "${data.vault_generic_secret.aws_auth.data["secret_key"]}"
  #profile = "${var.profile}"
  #profile = "dev"
  region     = "${var.region}"
}


#terraform #vault
Krit
Kritover 7 years ago
Question regardin module cloudposse/terraform-aws-s3-bucket: How can I enable “Static website hosting” on the bucket created via the module?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@AgustínGonzalezNicolini CloudPosse doesn’t have such a module, maybe other people here have it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Arvind
Arvindover 7 years ago
* provider.vault: failed to create limited child token: Error making API request.

URL: POST <https://vault.or1.net/v1/auth/token/create>
Code: 403. Errors:

* 1 error occurred:

* permission denied
Arvind
Arvindover 7 years ago
Any pointers
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
No experience with the vault provider.
Arvind
Arvindover 7 years ago
Is there any way I can use my AWS access and secret key from remote I don’t want to set environmental variables for aws access and secrets key or locally
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
in geodesic, we use assume role to login to diff accounts. But you will have to provision the required roles, and in your TF modules add the code for TF to assume the roles as well, e.g. https://github.com/cloudposse/terraform-root-modules/blob/master/aws/eks/main.tf#L11
Arvind
Arvindover 7 years ago
Let me integrate the same
Arvind
Arvindover 7 years ago
Thanks
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
geodesic uses aws-vault to store the credentials
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
It also supports aws-okta if you want to login with SAML provider
phanindra bolla
phanindra bollaover 7 years ago(edited)
Hi Guys, Question regarding ASL-ELB .
Once my stack are deployed with AWS ASG and a classic load balancer . Next terraform plan and apply is deregistering the instances behing the load balancer. I am unable to find the root cause for deregistering the instances . How do i make sure ASG instances are always registered under ELB
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@phanindra bolla it sounds more like terraform wants to recreate something and that's why they are getting deregistered.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
if you share the plan output, that would help more.
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Hi,

I was trying to run this code on my local https://www.terraform.io/docs/providers/helm/repository.html but receiving this error
helm_release.mydatabase: Couldn't load repositories file (helm/repository/repositories.yaml).
Vidhi Virmani
Vidhi Virmaniover 7 years ago(edited)
sorry this was my mistake I have set the home as ./helm. By removing home in provider fixed the issue
Steven
Stevenover 7 years ago
Sounds like your thinking more about AWS than DNS. This is an easy DNS issue. AWS has nothing to do with it. You can spread DNS subdomains across as many accounts as you want. I have multiple per account. You just need to create a NS record for each one in it's parent zone
Steven
Stevenover 7 years ago
As far as SSL, you need to add aliases when the SSL cert is created for each subdmain you want it to apply too
Steven
Stevenover 7 years ago(edited)
So, if you created a SSL cert for \.acme.co.uk you would have added an alias for \.develop.acme.co.uk to it
Steven
Stevenover 7 years ago
Can't without recreating the cert
Steven
Stevenover 7 years ago
SSL wildcards are single level only
Steven
Stevenover 7 years ago
What I do, is for each subdomain x.example.com I create a cert with \.x.example.com and \.example.com that everything in that subdomain can use
Steven
Stevenover 7 years ago
I also have 3 and 4 level SSL certs in my org
Steven
Stevenover 7 years ago
I organize multiple app environments per AWS account. We decided to reflect this as name spacing in DNS as app.env.account.company.com. I create SSL certs to handle all layers so I can create DNS aliases at any level
Steven
Stevenover 7 years ago(edited)
You can have many different certs for the same thing (*.example.com) as long as a given service only uses only one of them
Steven
Stevenover 7 years ago(edited)
Yes. It is easy there because it can be fully automated in terraform
Steven
Stevenover 7 years ago
It was also done this way to simplify terraform use. The run that setups up the route53 zone needs access to 2 AWS accounts (subdomain and parent domain accounts), but after that other terraform runs only need to use the subdomain account
phanindra bolla
phanindra bollaover 7 years ago
@Erik Osterman (Cloud Posse) Please checkout the terraform plan . This is what my plan changes when i re run the terraform life cycles .
Samuli
Samuliover 7 years ago
@oscarsullivan_old why do you think using ACM would invalidate your godaddy certs?
Samuli
Samuliover 7 years ago
You should first solve how you manage DNS..
Samuli
Samuliover 7 years ago
I don't know if godaddy supports delegating a subdomain to AWS but if it does not then you would have to migrate everything (DNS) to AWS
Samuli
Samuliover 7 years ago(edited)
After that ACM can use DNS to validate the domains you want to have SSL certs generated for
praveen
praveenover 7 years ago
Hi, Do we have an example of creating a cloud-init module with multiple cloud init configurations within it. So that the terraform code can source the cloud-init module and use specific cloud-init config from the cloud-init module. Can we make cloud-init template_file optional so that we can render specific template_file in terraform code depends on the requirement
praveen
praveenover 7 years ago
praveen
praveenover 7 years ago
making template_files optional and render only template_file what is needed for end terraform code >
Nikola Velkovski
Nikola Velkovskiover 7 years ago(edited)
Hi @praveen there's an open pr where this resource is being used
have a look,
https://github.com/cloudposse/terraform-aws-cloudwatch-agent/pull/1
it should help you getting started.
praveen
praveenover 7 years ago
Hi @Nikola Velkovski, My question was about cloud-init
praveen
praveenover 7 years ago
rendering terraform
praveen
praveenover 7 years ago
let me know if I am confusing you
Nikola Velkovski
Nikola Velkovskiover 7 years ago
check this file out
Nikola Velkovski
Nikola Velkovskiover 7 years ago
the resource is the same as the one you where asking about.
praveen
praveenover 7 years ago
@Nikola Velkovski the current example is sourcing multiple cloud init configurations and merging them. My requirement is to create separate cloud-init module, with all yaml files (configuration files ) required for complete environment is made available within it. For end Terraform code when I source the cloud-init module I should be able to render specific cloud-init config file for the specific service(without rendering all configuration files)
praveen
praveenover 7 years ago
which means the cloud-init module should omit(making all template_files optional) all cloud-init files and render specific file needed for the service/terraform code
praveen
praveenover 7 years ago
am i making sense. I mean, can this be achieved.
Nikola Velkovski
Nikola Velkovskiover 7 years ago
that will not be easily doable because of Yamls requirement for strict spacing. Maybe if passing the pieces base64 encoded.
praveen
praveenover 7 years ago
is it, let me prepare a module and test it to see if we can achieve it. I will share the module once i create
Nikola Velkovski
Nikola Velkovskiover 7 years ago
👍️
praveen
praveenover 7 years ago
As this approach being new, wanted to to check if it is doable
praveen
praveenover 7 years ago
Thank you Nikola
Nikola Velkovski
Nikola Velkovskiover 7 years ago
you are welcome
Steven
Stevenover 7 years ago
@praveen I did this type of thing in a different tool years ago. If you create a template for each cloud-init section and then either concat them together or use a template to put them together with a little conditional logic you should be able to do this
praveen
praveenover 7 years ago
hi Steven, can I have reference to the repo, so that I can refer to it
Steven
Stevenover 7 years ago
The one that I did was in puppet for a config file for something else. So, the logic would be different (also not sure where it is). But the concept should work. Probably will not be easy to debug or elegant
Steven
Stevenover 7 years ago
I remember in puppet it worked well, but the code was not easy to understand
praveen
praveenover 7 years ago
Sure Steven, let me create one and try. Thanks for the info Steven
Steven
Stevenover 7 years ago
welcome
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago(edited)
Office Hours
Today from 11:30 AM to 12:20 PM (PST) at https://zoom.us/j/684901853
Rich Allen
Rich Allenover 7 years ago
hiya, so forgive me if this a dumb question, but I'm new to the community and I've found you through the registry and it seems this is a fairly active set of maintained modules and contributers. I'm looking to reproduce something like https://docs.aws.amazon.com/quickstart/latest/compliance-nist/overview.html in terraform. I'm in the experiment stage and so I wrote a more simple public private subnet without peering or the addtional things in the diagram. At this point, I'm not exactly sure what bit's and pieces will make sense and how to best ultilze some of the modules and aim for something closer to my goal on this iteration.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
hey @Rich Allen welcome
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
it’s in CloudFormation, but should give you ideas what needs to be done
Rich Allen
Rich Allenover 7 years ago
yes, I was hoping to remain cloud agnostic about it for future purposes. We use aws right now, however for this particular need we'd also like to do other providers.
Rich Allen
Rich Allenover 7 years ago
it just seemed like this was common, and before I went out and wrote something
Rich Allen
Rich Allenover 7 years ago
just wanted to check in with some folks who might have advice or a module I was missing.
Rich Allen
Rich Allenover 7 years ago
your suggestion is my exact plan at the moment haha
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
yea, when you look at those templates, you will have more info on what needs to be implemented
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
also, TF is not cloud agnostic either, it’s just the same syntax, but different resources and modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
deprecation reverted 😃
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Hi,
Has someone tried to setup istio using terraform?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
As opposed to using helm?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
...otherwise, using terraform to call helm to install the official chart?
Raju
Rajuover 7 years ago
Hello
Raju
Rajuover 7 years ago
Raju
Rajuover 7 years ago
May be I am doing something wrong and one of you guys can help to sort it out
Ren Roz
Ren Rozover 7 years ago(edited)
Which one would you vote for... remote exec or userdata?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
hey @Raju did @Igor Rodionov get back to you?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
He's the one who wrote/maintains that module
Raju
Rajuover 7 years ago
Hi @Erik Osterman (Cloud Posse) Nops, I am yet waiting for a response on it
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@Raju sorry about that. @Igor Rodionov has been incredibly busy on another project. I’ll ping him again next week.
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
have you guys heard of pulumi? at this point, I have severe distaste of it
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
the general tone of the marketing, the ideal and its execution is pretty weak, and the fact that is a full SaaS service is a main issue for me
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
hi @Julio Tain Sueiras, we heard of it, looked at some examples, but did not actually use it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
i thought it was nice to try b/c it uses general purpose languages (Python, Go, Node) so could have much fewer restrictions than terraform
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
also can deploy k8s using the same language
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
@Erik Osterman (Cloud Posse) my big issue with pulumi is mostly stem from them piggybacking from terraform, but at the same time dissing terraform
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
(their provider is actually terraform provider)
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
@Andriy Knysh (Cloud Posse) my opinion about General purpose languages is , that it def can help with less restriction, but then at the same time move away from the ideal of the code is the infrastructure
kskewes
kskewesover 7 years ago
Look at the onboarding process of new employees with something like pulumi versus terraform.
Lot more skill with and best practices with the latter out there.
Abel Luck
Abel Luckover 7 years ago
has anyone used xterrafile to manage terraform deps ?
joshmyers
joshmyersover 7 years ago
Nope but looks interesting, seeing more and more of these small Terraform helper tools for managing and vendoring modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@Abel Luck do you know if it works recursively?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
(for modules composed of other modules)
Abel Luck
Abel Luckover 7 years ago
i haven't tried it yet, but that would be a requirement for my use case as well
Abel Luck
Abel Luckover 7 years ago
as much as i like the community taking the initiative to develop tools, i can't help but feel it should be a part of terraform proper.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
yea, we recently tried to do this with the help of @tamsky
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
it's not an easy problem to solve.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
nested modules, pinned at different versions of the same modules. we were able to mock up a prototype using terraform init to fetch all modules, parsed modules.json with jq to get the inventory, and did and some sed foo to rewrite sources to local ones.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
but the part that got messy is we couldn't really use a vendor/ folder b/c it would mean huge amounts of ../../../.././../vendor/github.com/cloudposse/terraform-null-label/0.4.5 type stuff
loren
lorenover 7 years ago
something like govendor/glide/etc for terraform.... With a true hcl parser/templater and round trip read/write support
loren
lorenover 7 years ago
I wonder if hashicorp would consider a terraform vendor or terraform package command ..?
tamsky
tamskyover 7 years ago(edited)
A TF_MODULES_LOAD_PATH var could help too
S
SweetOpsover 7 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.
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
@Andriy Knysh (Cloud Posse) have you guys used nix before?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@Julio Tain Sueiras what is nix?
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Looks interesting, we didn’t use it
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
the most interesting use of it for me is baking packages into docker image
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
so no more using ansible or Dockerfile to do apt install or yum install etc
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
is just
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago(edited)

contents = [
   vim
   terraform
]
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
johncblandii
johncblandiiover 7 years ago
Codefresh’s UI looks really good. There are some quality updates since the last UI I saw
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Yea, the are constantly improving it. In fact, there's even a newer UI than in this demo that they are about to release.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
That update will make it easier to visually deal with hundreds of repos and dozens of pipelines per repo.
shaiss
shaissover 7 years ago
anyone have exp w/ the TF ALB resource, particularly the access_logs block. I define an existing bucket, but get access denied. note that this is in dev, I created the bucket and the TF apply is running under my account
Steven
Stevenover 7 years ago
Specifically access denied to what?
shaiss
shaissover 7 years ago
aws_lb.alb_example: Failure configuring LB attributes: InvalidConfigurationRequest: Access Denied for bucket: shaitestiasapi[hidden]. Please check S3bucket permission
status code: 400, request id: 5ba27350-610e-11e9-af7f-1535341880fe
shaiss
shaissover 7 years ago
in cloudtrail I see `“errorCode”: “InvalidConfigurationRequestException”,
“errorMessage”: “Access Denied for bucket: shaitestiasapi[hidden]. Please check S3bucket permission”,
shaiss
shaissover 7 years ago
The AWS LB documention shows no references for access logs, so I’m wondering if this is a bug or old feature in TF: https://docs.aws.amazon.com/cli/latest/reference/elbv2/index.html
shaiss
shaissover 7 years ago
If I comment the access_log block out, then the TF template deploys fine:
# access_logs {
# bucket = “${var.s3_alb_logs_bucket}”
# prefix = “${var.log_prefix}”
# enabled = false
# }
Steven
Stevenover 7 years ago
Your account needs permissions to S3 bucket to setup and LB needs permissions to write the logs
shaiss
shaissover 7 years ago
are there any particular permissions?
shaiss
shaissover 7 years ago
I have full admin
Steven
Stevenover 7 years ago
Then you're good for the terraform run. But you need to give the LB permissions to S3
Steven
Stevenover 7 years ago
Should be an example of that somewhere
shaiss
shaissover 7 years ago
@Steven thx for the help, yep, I’m looking for that example as that’s the part that’s holding me back
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
here’s how we create S3 bucket with policy for LB logs (it’s Elastic Beanstalk, but should be the same for any LB) https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/blob/master/main.tf#L1029
shaiss
shaissover 7 years ago
ty!
johncblandii
johncblandiiover 7 years ago(edited)
Hashicorp email just came through
Maybe You Don’t Need Kubernetes, Unleashing Terraform 0.12, and Nomad 0.9 & Vault 1.1 Releases
giphy
giphyover 7 years ago
johncblandii
johncblandiiover 7 years ago
^ me right now at seeing .12 mentioned
johncblandii
johncblandiiover 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Office Hours
Today from 11:30 AM to 12:20 PM at https://zoom.us/j/684901853
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
(PST)
shaiss
shaissover 7 years ago
has anyone runinto challenges deploying an s3 bucket when the role has a policy w/ s3:GetBucketWebsite deny?
shaiss
shaissover 7 years ago
* aws_s3_bucket.b: aws_s3_bucket.b: error getting S3 Bucket website configuration: AccessDenied: Access Denied
status code: 403, request id: 58F8BCE915142469, host id: BJd1A2Zr/RhBG7CNU+zOe4cFoCW63zt+h9ea6jsqC/D7fl3x90uxIrvBIVMezFY8sr5/yxNYdZ0=
shaiss
shaissover 7 years ago
resource “aws_s3_bucket” “b” {
bucket = “my-tf-test-buckeas231231232144445”
acl = “private”

tags = {
Name = “test bucket”
Environment = “Dev”
}
}

provider “aws” {
region = “us-east-1"
}
shaiss
shaissover 7 years ago
that’s the TF code, nothing else
shaiss
shaissover 7 years ago
IAM policy:
{
“Version”: “2012-10-17",
“Statement”: [
{
“Sid”: “VisualEditor0”,
“Effect”: “Deny”,
“Action”: [
“s3:DeleteBucketWebsite”,
“s3:GetBucketWebsite”,
“s3:PutBucketWebsite”
],
“Resource”: “*”
}
]
}
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you denied those actions. any reason for doing it?
shaiss
shaissover 7 years ago
not my env, customers that insists those have to be denied
loren
lorenover 7 years ago
heh, chicken, meet egg
loren
lorenover 7 years ago
might need some kind of condition on the statement such that it doesn't apply to whatever principal you want to use to apply the tf config
shaiss
shaissover 7 years ago
yeah, that’s what I’m thinking, but oddly I can run the create bucket via CLI with no issues. So TF is doing something with the CLI call beyond the basics I’m asking it to do
loren
lorenover 7 years ago
yes, TF does a lot of "get"-type calls to check state
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@shaiss do you create the same policy with Deny when using cli?
shaiss
shaissover 7 years ago
policy is already their when they setup the account
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
hmm…
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
both TF and cli call the same AWS API
loren
lorenover 7 years ago
The AWS cli is only doing the create bucket though, TF is trying to manage all the attributes on the bucket and so queries the current state first
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
No, that would be a security hole :) the policy is already in the account as I understand it
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
@shaiss might be creating S3 website bucket in TF (not actually using the code shown above), but just plain bucket from the cli
loren
lorenover 7 years ago
i'm not following that... his role/user is not allowed the s3:GetBucketWebsite action, but TF is clearly attempting to do exactly that
shaiss
shaissover 7 years ago
@Andriy Knysh (Cloud Posse) that shouldn’t be the case w/ the TF code I posted above as it’s pulled directly from the Terraform doc for creating a basic bucket
shaiss
shaissover 7 years ago
@loren exactly
loren
lorenover 7 years ago
all i'm saying is that TF makes many api calls when it refreshes state, because TF isn't doing a single api action in an s3_bucket resource
shaiss
shaissover 7 years ago
I love to see the underlying API call TF is making, I enabled tracing but the output is still a bit cryptic
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
if the policy is a resource (bucket) policy, creating S3 website would not work in any case
shaiss
shaissover 7 years ago
@Andriy Knysh (Cloud Posse) the policy is an IAM policy
shaiss
shaissover 7 years ago
that IAM policy is attached to the role I’m assuming
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Identity-based policies – Attach managed and inline policies to IAM identities (users, groups to which users belong, or roles). Identity-based policies grant permissions to an identity.

Resource-based policies – Attach inline policies to resources. The most common examples of resource-based policies are Amazon S3 bucket policies and IAM role trust policies. Resource-based policies grant permissions to a principal entity that is specified in the policy. Principals can be in the same account as the resource or in other accounts.
loren
lorenover 7 years ago(edited)
set yourself up with a throwaway aws account for the free tier, then setup a role with zero read privs, use that with TF to create the bucket. then you'll see all the aws api calls that TF is performing, as you get denied one-by-one, grant yourself that specific api read action
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago

that IAM policy is attached to the role I’m assuming
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
are you assuming the same role when using the cli?
loren
lorenover 7 years ago
in TF, a different set of api actions is required to create the bucket the first time vs applying the config again (even with no changes) due to the extra read cycle
loren
lorenover 7 years ago
skim that file for s3conn. to get an idea of the api actions required
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
i’m just trying to say that if @shaiss assumes the role with the policy when using TF, then it will not work b/c/ of the permissions. With cli, if he assumes the same role, it should not work either. If he uses another way to login with cli, then it would work since the policy is not attached to the other credentials. If he assumes the same role using cli and it works, then it’s very strange 🙂
loren
lorenover 7 years ago(edited)
right, the difference is that with the aws cli, the only thing he did is create-bucket
loren
lorenover 7 years ago
TF does much more than just create-bucket when operating on an aws_s3_bucket resource
shaiss
shaissover 7 years ago
@Andriy Knysh (Cloud Posse) I assume the role w/ both TF and CLI, and CLI works, TF fails
shaiss
shaissover 7 years ago
@loren is on the right path here.
shaiss
shaissover 7 years ago
it’s those additional things that TF is doing that in this case fails b/c the customer insists on having that IAM policy attached to ALL roles
loren
lorenover 7 years ago(edited)
i can't really imagine why they'd want to restrict s3:GetBucketWebsite on all buckets, that just means they can't even confirm that the buckets do not have a website configured, as you're seeing :rofl:
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
yea agree, that permission should be lifted since it’s just read-only anyway
shaiss
shaissover 7 years ago
@loren I agree, but atm they won’t budge, so before I argue that point, I want to make sure there’s no other Terraform way around this
loren
lorenover 7 years ago
looking at the TF code, i don't see a way. TF needs it to execute its "read" operation on the bucket
loren
lorenover 7 years ago
and without supporting the "read" operation, there isn't much point in using TF
shaiss
shaissover 7 years ago
maybe I just need to fork it and remove that 😛
shaiss
shaissover 7 years ago
I’ll call it shaiform
loren
lorenover 7 years ago
lulz
loren
lorenover 7 years ago
from the TF code, it does look like the bucket should have been created... it would be after that when TF attempts the read operation that fails... can you double-check that maybe?
shaiss
shaissover 7 years ago
it does indeed create the bucket
shaiss
shaissover 7 years ago
but the customer would still say the terraform code is invalid because of that error
loren
lorenover 7 years ago
i mean, you could try to submit an issue asking that the TF provider be more considerate of insanely restrictive IAM policies and illogical customers 😛
loren
lorenover 7 years ago
since the TF config doesn't specify an s3 website config, TF could key on that absence to avoid the calls
Maxim Tishchenko
Maxim Tishchenkoover 7 years ago
guys, is there any way to user archive_file zip with -X argument?
because every time when I do apply, .zip change timestamp, and upload lambda function
I want to stop it. and do upload when it changed only
Gabor Csikos
Gabor Csikosover 7 years ago
there are usecases and workarounds on github issues of (probably aws provider?) , they build around lifecycle { ignore_changes } feature of TF
Maxim Tishchenko
Maxim Tishchenkoover 7 years ago
yes, aws provider
Maxim Tishchenko
Maxim Tishchenkoover 7 years ago
@Gabor Csikos could you do me a favour and provide a link to ignore_changes feature?
Maxim Tishchenko
Maxim Tishchenkoover 7 years ago

  lifecycle {
    ignore_changes = ["filename"]
  }
Maxim Tishchenko
Maxim Tishchenkoover 7 years ago
I found
dalekurt
dalekurtover 7 years ago
Is anyone using the terraform-aws-eks-cluster TF module?
dalekurt
dalekurtover 7 years ago
Using the example provided, I’m having the following issue:

Error: Error running plan: 5 error(s) occurred:

* module.eks_cluster.output.eks_cluster_id: Resource 'aws_eks_cluster.default' does not have attribute 'id' for variable 'aws_eks_cluster.default.*.id'
* module.eks_cluster.output.eks_cluster_version: Resource 'aws_eks_cluster.default' does not have attribute 'version' for variable 'aws_eks_cluster.default.*.version'
* module.eks_cluster.local.certificate_authority_data_list: local.certificate_authority_data_list: Resource 'aws_eks_cluster.default' does not have attribute 'certificate_authority' for variable 'aws_eks_cluster.default.*.certificate_authority'
* module.eks_cluster.output.eks_cluster_arn: Resource 'aws_eks_cluster.default' does not have attribute 'arn' for variable 'aws_eks_cluster.default.*.arn'
* module.eks_cluster.output.eks_cluster_endpoint: Resource 'aws_eks_cluster.default' does not have attribute 'endpoint' for variable 'aws_eks_cluster.default.*.endpoint'
 
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
it’s tested many times, and many people have deployed EKS cluster using it
dalekurt
dalekurtover 7 years ago
@Andriy Knysh (Cloud Posse) Yes, i’m actually using that
dalekurt
dalekurtover 7 years ago
I will give another go with a clean slate.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@Andriy Knysh (Cloud Posse) should we pin the AWS provider on that module?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
yea, good idea, we pin all dependencies except the provider
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
i think we need to since the provider has been breaking so much stuff
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
I’ll open PRs
johncblandii
johncblandiiover 7 years ago
the provider broke stuff on us recently
johncblandii
johncblandiiover 7 years ago
all things were blocked; very disappointing
johncblandii
johncblandiiover 7 years ago
@dalekurt I’m using the EKS module. i haven’t seen that issue
dalekurt
dalekurtover 7 years ago
Thanks @johncblandii @Andriy Knysh (Cloud Posse) I plowed through that and now i’m solving for the following

Error: Error refreshing state: 1 error(s) occurred:

* module.eks_workers.data.aws_ami.eks_worker: 1 error(s) occurred:

* module.eks_workers.data.aws_ami.eks_worker: data.aws_ami.eks_worker: Your query returned no results. Please change your search criteria and try again.

Gabe
Gabeover 7 years ago
does anyone have experience with https://docs.geopoiesis.io?
Gabe
Gabeover 7 years ago
looks like atlantis but seems to have a nicer interface and ability to limit user access better
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
oh right! thanks for bringing that back to my attention
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago(edited)
@antonbabenko might have some experience (by now)
johncblandii
johncblandiiover 7 years ago
So it is a Terraform Enterprise competitor with a 100x worse name? 👀 🙂
johncblandii
johncblandiiover 7 years ago
I kid.
johncblandii
johncblandiiover 7 years ago

terraforming

geo = earth, poiesis = making

“second, there is the principle of gaian geopoiesis, a global principle of self-organization, that trumps the interests of individuals and species.”


Learn something new every day; still can’t pronounce it. 😄
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Yea the name is overboard
erik
erikover 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
That’s nice to see each stage and changes pending
loren
lorenover 7 years ago
Very cool
loren
lorenover 7 years ago
johncblandii
johncblandiiover 7 years ago
uh oh….can’t wait
johncblandii
johncblandiiover 7 years ago
SEARCH IN THE DOCS!! SEARCH IN THE DOCS!! SEARCH IN THE DOCS!! SEARCH IN THE DOCS!! SEARCH IN THE DOCS!! SEARCH IN THE DOCS!!

https://www.terraform.io/docs/providers/index.html
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
nice - looks like they revamped the docs
loren
lorenover 7 years ago
Google probably still faster 😛
johncblandii
johncblandiiover 7 years ago
lmbo. prob so
Joe Presley
Joe Presleyover 7 years ago
What's the recommended workflow for secrets management with terraform and the google cloud provider?
Joe Presley
Joe Presleyover 7 years ago
I'm curious if there's a non-vault way that's as easy as the AWS's KMS integration with terraform.
dalekurt
dalekurtover 7 years ago
Has anyone successfully deployed the reference-architectures? I’m currently using it for my company but I’m not getting a successful deployment. I would love some help troubleshooting this
https://github.com/cloudposse/reference-architectures
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@dalekurt best to ask in #geodesic for now
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Maybe should create dedicated channel
dalekurt
dalekurtover 7 years ago
Thanks @Erik Osterman (Cloud Posse)
dalekurt
dalekurtover 7 years ago
by now you have figured out I’m using a lot of your terraform modules on numerous projects. I’m trying to get this Terraform module <https://github.com/cloudposse/terraform-aws-eks-cluster> but I’m coming up with a single error

Error: Error refreshing state: 1 error(s) occurred:

* module.eks_workers.data.aws_ami.eks_worker: 1 error(s) occurred:

* module.eks_workers.data.aws_ami.eks_worker: data.aws_ami.eks_worker: Your query returned no results. Please change your search criteria and try again.

The module

data "aws_ami" "eks_worker" {
  count = "${var.enabled == "true" && var.use_custom_image_id == "false" ? 1 : 0}"

  most_recent = true
  name_regex  = "${var.eks_worker_ami_name_regex}"

  filter {
    name   = "name"
    values = ["${var.eks_worker_ami_name_filter}"]
  }

  most_recent = true
  owners      = ["602401143452"] # Amazon
}
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@dalekurt what AWS region and what version (release) of the module are you using?
dalekurt
dalekurtover 7 years ago
@Andriy Knysh (Cloud Posse) us-east-1 and master
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
the AMI search and filter were changed in recent PRs, You can create a separate project using just the code above, and try to update eks_worker_ami_name_regex and/or eks_worker_ami_name_filter to see what’s returned. If nothing returned, then the AMI list has already been changed in AWS, try to change eks_worker_ami_name_regex to see if you can find any EKS AMIs
dalekurt
dalekurtover 7 years ago
Okay, I was on the right track for resolving this. I will try that after my stand up. Thank you very much 🙏
dalekurt
dalekurtover 7 years ago
@Andriy Knysh (Cloud Posse) Confirmed, I created a new project for the EKS cluster using the example and the result was the same. I will look into the eks_worker_ami_name_regex
dalekurt
dalekurtover 7 years ago
I defined a terraform.tfvars with

eks_worker_ami_name_filter = "amazon-eks-node-*"
eks_worker_ami_name_regex = "^amazon-eks-node-[1-9,\\.]+-v\\d{8}$"
`
Which got me past that issue.

Now I get the following

------------------------------------------------------------------------

Error: Error running plan: 5 error(s) occurred:

* module.eks_cluster.output.eks_cluster_id: Resource 'aws_eks_cluster.default' does not have attribute 'id' for variable 'aws_eks_cluster.default.*.id'
* module.eks_cluster.output.eks_cluster_endpoint: Resource 'aws_eks_cluster.default' does not have attribute 'endpoint' for variable 'aws_eks_cluster.default.*.endpoint'
* module.eks_cluster.local.certificate_authority_data_list: local.certificate_authority_data_list: Resource 'aws_eks_cluster.default' does not have attribute 'certificate_authority' for variable 'aws_eks_cluster.default.*.certificate_authority'
* module.eks_cluster.output.eks_cluster_version: Resource 'aws_eks_cluster.default' does not have attribute 'version' for variable 'aws_eks_cluster.default.*.version'
* module.eks_cluster.output.eks_cluster_arn: Resource 'aws_eks_cluster.default' does not have attribute 'arn' for variable 'aws_eks_cluster.default.*.arn'



I have to define the certificate data for one of those errors.
C
Cloud Posseover 7 years ago
Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7).

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Mar 20, 2019 11:30AM.

👉️ Add it to your calendar

:zoom: https://zoom.us/j/684901853

:slack: #office-hours (our channel)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
no specific reason, could be written both ways
Dan
Danover 7 years ago
Is there an example out there of how to do a list of ports with aws terraform security groups?
Tim Malone
Tim Maloneover 7 years ago
If they’re all in order, you could just do a range - from and to.
Otherwise, I’d probably put them into a local variable as a list and build the rules from that with count.
Tim Malone
Tim Maloneover 7 years ago
Something like:
locals {
  ports = [80, 443]
}

resource “aws_security_group_rule” “main” {
  count = “${length(local.ports)}”
  ...
  from = “${local.ports[count.index]}”
  ...
}
Dan
Danover 7 years ago
Also, I'm trying to create generic automation builds... Is there a way to somthing like this:
If a user has a subnet they want the instance in then they can input that subnet
else create a subnet to put the instance in
but dont create a subnet if they do put a subnet in...
Tim Malone
Tim Maloneover 7 years ago
you could create a variable that defaults to an empty string
and then use count = "${var.subnet = "" ? 1 : 0}" on your subnet resource to only create it if the variable is blank
Dan
Danover 7 years ago
How would you get resources to select whichever one had a value?
Tim Malone
Tim Maloneover 7 years ago
use a similar conditional 🙂
Tim Malone
Tim Maloneover 7 years ago(edited)
subnet = "${var.subnet = "" ? ..... : var.subnet}"
Stephen Lawrence
Stephen Lawrenceover 7 years ago
Utilizing the VPC Peering module. I am getting this regardless if I use VPCID's or VPC Tags for the selector: data.aws_vpc.requestor: multiple VPCs matched; use additional constraints to reduce matches to a single VPC
Stephen Lawrence
Stephen Lawrenceover 7 years ago(edited)
Each of my VPC's are uniquely named and have unique vpc ID's obviously.
Stephen Lawrence
Stephen Lawrenceover 7 years ago
Ah, nevermind. I had two blocks of VPC peering module in my main.tf. 😐️
Dan
Danover 7 years ago
Can you iterate over nested blocks in Terraform?
Nikola Velkovski
Nikola Velkovskiover 7 years ago
just found a weird behavior in terraform
Nikola Velkovski
Nikola Velkovskiover 7 years ago

locals {
  tasks = {
    main_num  = 200
    other_num = "${local.tasks["main_num"] + (local.tasks["main_num"] * 0.50)}"
  }
}

output "other_num" {
  value = "${local.tasks["other_num"]}"
}

output "main_num" {
  value = "${local.tasks["main_num"]}"
}
Nikola Velkovski
Nikola Velkovskiover 7 years ago
this empties the whole tasks map!
Ankur
Ankurover 7 years ago
Can someone point me to sample terraform project which pulls a docker image from dockerhub and deploys into ecs ?
Jan
Janover 7 years ago(edited)
I can use it perfectly fine via the geodesic images but struggling via a jenkins pipeline
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
hey @Jan, we deployed it to a client recently
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago(edited)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
@Jan it needs to be able to assume role into multiple accounts
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
Does Jenkins have that permission?
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Can anyone help me understand this error
 kubernetes_service_account.tiller: 1 error(s) occurred:

* kubernetes_service_account.tiller: Post <http://localhost/api/v1/namespaces/kube-system/serviceaccounts>: dial tcp [::1]:80: connect: connection refused
Tim Malone
Tim Maloneover 7 years ago
sounds like your k8s cluster API isn’t accessible
Tim Malone
Tim Maloneover 7 years ago
you’re running it locally, right? is it definitely up, etc.?
Vidhi Virmani
Vidhi Virmaniover 7 years ago
no running through terraform enterprise.
Vidhi Virmani
Vidhi Virmaniover 7 years ago
maybe i need to set kubernetes provider. I am only relying on helm kubernetes config
Tim Malone
Tim Maloneover 7 years ago
yeah it looks like it’s trying to connect to a local cluster, which won’t work in enterprise
you’ll need to set the host and access details for the kubernetes provider
Vidhi Virmani
Vidhi Virmaniover 7 years ago
Thanks @Tim Malone 🙂 it works now.
Abel Luck
Abel Luckover 7 years ago
I want to set a local value in terraform, the value should be the value from a data provider, if the value exists, otherwise a value from a variable.. anyone know if this is possible?
Abel Luck
Abel Luckover 7 years ago
in psuedo non-hcl code: local foobar = data.something.foobar != null ? data.something.foobar : var.default_foobar
Abel Luck
Abel Luckover 7 years ago
hm i suppose a ternary might work in the interpolation?
Nikola Velkovski
Nikola Velkovskiover 7 years ago
@Abel Luck why not ? 🙂
Nikola Velkovski
Nikola Velkovskiover 7 years ago

data "aws_ami" "test" {
  most_recent = true

  filter {
    name   = "name"
    values = ["Deep Learning AMI (Ubuntu)*"]
  }

  owners = [
    "amazon",
  ]
}

locals {
  abel = "${data.aws_ami.test.id != "" ? data.aws_ami.test.id : "bar"}"
}

output "abel" {
  value = "${local.abel}"
}
Nikola Velkovski
Nikola Velkovskiover 7 years ago(edited)
although the data.aws_ami resource is a poor example since it fails when not being able to match any amis but the logic is the same with whatever you are using.
C
Cloud Posseover 7 years ago
Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7).

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Mar 20, 2019 11:30AM.

👉️ Add it to your calendar

:zoom: https://zoom.us/j/684901853

:slack: #office-hours (our channel)
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
@Andriy Knysh (Cloud Posse) hi?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
Hi @Julio Tain Sueiras
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
so 😃 , I have officially started on the LSP implementation for terraform
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
and from what I am seeing so far, once I have the base configs for parsing done, the completion will be reading for not just resources but for any user defined object variable
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
so is going to be a very interesting approach
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
got somestuff working
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
it will be hcl2 parser inside the terraform to parse the source code, then adapt tfschema to use go-plugin grpc to call the provider binary directly to get the schema
Julio Tain Sueiras
Julio Tain Sueirasover 7 years ago
since terraform have split the providers
cabrinha
cabrinhaover 7 years ago
what do we all think of modules containing A LOT of data lookups?
we have our own module, called "aws", and this module ... we're thinking about putting a ton of data lookups we use all the time
but, seems that whenever we call the module, all the data lookups get evaluated
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 7 years ago
We've done this before and it "works" however it totally breaks cold-starts
cabrinha
cabrinhaover 7 years ago
friend of mine saying it'll end up beating up the aws api
cabrinha
cabrinhaover 7 years ago
i thought there was a way to have data lookups evaluated only when you use them
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
@cabrinha if data sources are in the code, they will be evaluated with terraform plan (and apply of cause)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
you can use count in data sources if you want to disable them https://www.terraform.io/docs/configuration/data-sources.html#multiple-resource-instances
cabrinha
cabrinhaover 7 years ago
thanks
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
generally it works ok when everything is already created and in good state
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)over 7 years ago
issues could arise during cold start (as @Erik Osterman (Cloud Posse) mentioned) and with terraform destroy