Skip to content

Commit

Permalink
Merge pull request #341 from apex/add_aws_region
Browse files Browse the repository at this point in the history
add passing aws_region var to Terraform
  • Loading branch information
mthenw committed Mar 22, 2016
2 parents 4136853 + 6be3e44 commit 4fe6290
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion _examples/api-gateway/infrastructure/dev/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by `apex init`
variable "aws_region" {}

module "iam" {
Expand Down
3 changes: 2 additions & 1 deletion boot/boilerplate/_boilerplate/infrastructure/_env/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
variable "aws_region" {}

module "iam" {
source = "../modules/iam"
}

output "lambda_function_role_id" {
value = "${module.iam.lambda_function_role_id}"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

resource "aws_iam_role" "lambda_function" {
name = "lambda_function"
name = "apex_lambda_function"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
Expand Down
8 changes: 4 additions & 4 deletions boot/boilerplate/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion infra/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (p *Proxy) Run(args ...string) error {

// functionVars returns the function ARN's as terraform -var arguments.
func (p *Proxy) functionVars() (args []string) {
args = append(args, "-var")
args = append(args, fmt.Sprintf("aws_region=%s", p.Region))

for _, fn := range p.Functions {
config, err := fn.GetConfig()
if err != nil {
Expand All @@ -69,7 +72,7 @@ func (p *Proxy) shouldInjectVars(args []string) bool {
return false
}

return args[0] == "plan" || args[0] == "apply"
return args[0] == "plan" || args[0] == "apply" || args[0] == "destroy"
}

// Output fetches output variable `name` from terraform.
Expand Down

0 comments on commit 4fe6290

Please sign in to comment.