Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Terraform var for Tilegarden function name #729

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ $ cp ./src/tilegarden/.env.example ./src/tilegarden/.env

Edit the new file to fill in or adjust variables. The required variables are:
- `AWS_PROFILE`: the name of the AWS credentials profile you created above, e.g. "pfb"
- `PROJECT_NAME`: a name to identify this deployment, which should include the environment name
- `LAMBDA_FUNCTION_NAME`: a name to identify this deployment, which should include the environment name
- `LAMBDA_REGION`
- `LAMBDA_ROLE`: the role the Lambda function should run under. Use the one created by Terraform, e.g. "pfbStagingTilegardenExecutor"

Expand Down
4 changes: 2 additions & 2 deletions deployment/terraform/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ data "aws_iam_policy_document" "lambda_assume_role" {
data "aws_iam_policy_document" "lambda_invoke" {
statement {
effect = "Allow"
resources = ["*"]
resources = ["arn:aws:lambda:*:*:function:${var.tilegarden_function_name}"]
actions = [
"lambda:InvokeFunction",
]
Expand Down Expand Up @@ -263,7 +263,7 @@ data "aws_iam_policy_document" "s3_write_tile_cache" {
}

resource "aws_iam_role" "tilegarden_executor" {
name = "pfb${var.environment}TilegardenExecutor"
name = "${var.tilegarden_function_name}Executor"
assume_role_policy = "${data.aws_iam_policy_document.lambda_assume_role.json}"
}

Expand Down
3 changes: 3 additions & 0 deletions deployment/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ variable "tilegarden_api_gateway_domain_name" {}
variable "cloudfront_price_class" {
default = "PriceClass_100"
}

# Should be environment-specific and match the value in the Tilegarden .env file
variable "tilegarden_function_name" {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to get added to the .tfvars files on S3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, will do.

6 changes: 2 additions & 4 deletions src/tilegarden/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
# If you want to set them specifically, change them to assignments
AWS_PROFILE

# Name of the lambda function
PROJECT_NAME=
# Name of the lambda function. Should match the `tilegarden_function_name` Terraform variable.
LAMBDA_FUNCTION_NAME=

# Function config information
## REQUIRED ##
LAMBDA_REGION=

# name of role associated with this lambda function (created by Terraform)
LAMBDA_ROLE=role-name
# Amount of time in seconds your lambdas will run before timing out.
# Default is 3, so some override is necessary.
LAMBDA_TIMEOUT=
Expand Down
6 changes: 4 additions & 2 deletions src/tilegarden/scripts/deploy-new
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

yarn claudia create --config claudia/claudia.json --no-optional-dependencies \
--api-module dist/api --name ${PROJECT_NAME} --region ${LAMBDA_REGION} \
${LAMBDA_ROLE:+--role ${LAMBDA_ROLE}} \
--api-module dist/api \
--name ${LAMBDA_FUNCTION_NAME} \
--region ${LAMBDA_REGION} \
--role "${LAMBDA_FUNCTION_NAME}Executor" \
${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} \
${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} \
${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} \
Expand Down