# Engineering Elixir Applications: End of Chapter 2, github\_issues\_labels

**URL:** <https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474>\
**Category:** PragProg Customers\
**Tags:** book-engineering-elixir-applications, errata\
**Created:** [18 June 2024 17:10 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474 "2024-06-18T17:10:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoldierCoder](https://forum.devtalk.com/user_avatar/forum.devtalk.com/soldiercoder/32/5305_2.png) [@SoldierCoder](https://forum.devtalk.com/u/SoldierCoder)\
**Post date:** [18 June 2024 17:10 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474/1 "2024-06-18T17:10:58Z")

</div>

@elliefairholm and @Gilacost

All of Chapter 2 works fine until this last bit.  
variable “issues” {  
type = list(object({  
title = string  
body = string  
labels = list(string)  
milestone = string  
}))  
}

resource “github\_issue” “tasks” {  
count = length(var.issues)  
repository = github\_repository.kanban.name  
title = var.issues[count.index].title  
body = var.issues[count.index].body  
milestone\_number = github\_repository\_milestone.epics[var.issues[count.index].milestone].number  
labels = [for l in var.issues[count.index].labels :  
github\_issue\_label.issues\_labels[l].name]

Error: Invalid index  
│  
│ on main.tf line 77, in resource “github\_issue” “tasks”:  
│ 77: github\_issue\_label.issues\_labels[l].name]  
│ ├────────────────  
│ │ github\_issue\_label.issues\_labels is object with 15 attributes  
│  
│ The given key does not identify an element in this collection value.

---

<div class="post-metadata">

**Author:** ![elliefairholm](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/e/e0b2c6/32.png) [@elliefairholm](https://forum.devtalk.com/u/elliefairholm)\
**Post date:** [1 July 2024 19:06 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474/2 "2024-07-01T19:06:51Z")

</div>

Hi @SoldierCoder could you share your whole main.tf and .auto.tfvars files? It looks like your having an issue when trying to access a specific “github\_issue\_label.issues\_labels” resource. Rather than having many “issue\_labels” in your state it seems that you only have one.

---

<div class="post-metadata">

**Author:** ![SoldierCoder](https://forum.devtalk.com/user_avatar/forum.devtalk.com/soldiercoder/32/5305_2.png) [@SoldierCoder](https://forum.devtalk.com/u/SoldierCoder)\
**Post date:** [19 July 2024 22:25 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474/3 "2024-07-19T22:25:25Z")

</div>

.auto.tfvars  
milestones = {  
“infrastructure” = {  
title = “Infrastructure”  
due\_date = “2024-07-12”  
description = \<\<EOT  
This milestone includes all the deliverables related to building the application(e.g. Dockerfile), provisioning AWS, the local environment and the base AMI (Amazon Machine Image) with Packer.  
EOT  
},  
“ci-cd” = {  
title = “Continuous Deployment / Continuous Integration”  
due\_date = “2024-07-12”  
description = \<\<EOT  
This milestone will include all deliverables that have to do with GitHub workflows that will perform the basic checks for an Elixir application. It will also build the Docker  
image and pull the latest images in production.  
EOT  
},  
“instrumentation” = {  
title = “Instrumentation”  
due\_date = “2024-07-01”  
description = \<\<EOT  
This milestone will include all deliverables that have to do with the addition of basic instrumentation and BEAM specific metrics for your application. Any task(s) related  
to instrumentation (independently of which part of the stack they relate to) will be included in this milestone.  
EOT  
},  
“documentation” = {  
title = “Documentation”  
due\_date = “”  
description = \<\<EOT  
This milestone includes documentation for Terraform, Elixir, Packer and others and will converge with CI when needed.  
EOT  
},  
“uncategorized” = {  
title = “Uncategorized”  
due\_date = “”  
description = \<\<EOT  
A milestone to add all issues that do not fit in any of the other milestones. This is a way to track those uncategorized tasks in an easy way.  
EOT  
}  
}

labels = {  
“kind-infrastructure” = {  
name = “Kind:Infrastructure”  
color = “B60205”  
},  
“kind-ci-cd” = {  
name = “Kind:CI-CD”  
color = “FBCA04”  
},  
“kind-instrumentation” = {  
name = “Kind:Instrumentation”  
color = “0E8A16”  
},  
“kind-documentation” = {  
name = “Kind:Documentation”  
color = “5319E7”  
},  
“kind-uncategorized” = {  
name = “Kind:Uncategorized”  
color = “D93F0B”  
},  
“tech-docker” = {  
name = “Tech:Docker”  
color = “1D76DB”  
},  
“dockerfile” = {  
name = “Kind:Dockerfile”  
color = “3895Ad”  
},  
“tech-elixir” = {  
name = “Tech:Elixir”  
color = “D981FC”  
},  
“tech-gha” = {  
name = “Tech:GHA”  
color = “66FE68”  
},  
“tech-docker-compose” = {  
name = “Tech:Docker-Compose”  
color = “006B75”  
},  
“tech-packer” = {  
name = “Tech:Packer”  
color = “1D76DB”  
},  
“tech-terraform” = {  
name = “Tech:Terraform”  
color = “5319A1”  
},  
“tech-sops” = {  
name = “Tech:SOPS”  
color = “F9D0C4”  
},  
“env-aws” = {  
name = “Env:AWS”  
color = “D3A968”  
},  
“env-local” = {  
name = “Env:Local”  
color = “0075CA”  
}  
}

issues = [  
{  
title = “Implement the Dockerfile’s builder stage”  
body = \<\<EOT  
The builder stage packages all the tools and compile-time dependencies for your  
application. It has to build the mix release that will be copied in the running  
stage.  
EOT  
labels = [“kind-infrastrcture”, “dockerfile”]  
milestone = “infrastructure”  
},  
{  
title = “Implement the Dockerfile’s runner stage”  
body = \<\<EOT  
This stage copies the release built in the builder stage and uses it as the  
entrypoint of your Docker image with the minimum system requirement to run it.  
EOT  
labels = [“kind-infrastructure”, “dockerfile”]  
milestone = “infrastructure”  
},  
{  
title = “Elixir integration pipelines”  
body = \<\<EOT  
Implement a CI pipeline that includes all of the necessary steps when delivering an  
Elixir application: code compilation, dependency caching, testing, code  
formatting, and an used dependency check.  
EOT  
labels = [“kind-ci-cd”, “tech-elixir”]  
milestone = “ci-cd”  
}  
]

---

<div class="post-metadata">

**Author:** ![SoldierCoder](https://forum.devtalk.com/user_avatar/forum.devtalk.com/soldiercoder/32/5305_2.png) [@SoldierCoder](https://forum.devtalk.com/u/SoldierCoder)\
**Post date:** [19 July 2024 22:28 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474/4 "2024-07-19T22:28:06Z")

</div>

### Ellie Fairholm @elliefairholm and Josep Giralt D’Lacoste @Gilacost

main.tf

terraform {  
required\_providers {  
github = {  
source = “integrations/github”  
version = “~\> 6.0”  
}  
}  
}

locals {  
repository\_name = “kanban”  
github\_owner = “SoldierCoder”  
}

resource “github\_repository” “kanban” {

name = local.repository\_name  
description = “Taking the BEAM to production pragmatically.”  
visibility = “private”  
has\_issues = true  
auto\_init = true  
gitignore\_template = “Terraform”  
delete\_branch\_on\_merge = true  
vulnerability\_alerts = true  
has\_discussions = true  
has\_projects = true  
}

variable “milestones” {  
type = map(object({  
title = string  
due\_date = string  
description = string  
}))  
description = “Milestones, consider them the biggest deliverable unit.”  
}

resource “github\_repository\_milestone” “epics” {  
depends\_on = [github\_repository.kanban]  
for\_each = var.milestones  
owner = local.github\_owner  
repository = local.repository\_name  
title = each.value.title  
description = replace(each.value.description, “\n”, " ")  
due\_date = each.value.due\_date  
}

variable “labels” {  
type = map(object({  
name = string  
color = string  
}))  
description = “The labels to tag the issues.”  
}

resource “github\_issue\_label” “issues\_labels” {  
depends\_on = [github\_repository.kanban]  
for\_each = var.labels  
repository = local.repository\_name  
name = each.value.name  
color = each.value.color  
}

variable “issues” {  
type = list(object({  
title = string  
body = string  
labels = list(string)  
milestone = string  
}))  
}

resource “github\_issue” “tasks” {  
count = length(var.issues)  
repository = github\_repository.kanban.name  
title = var.issues[count.index].title  
body = var.issues[count.index].body  
milestone\_number = github\_repository\_milestone.epics[var.issues[count.index].milestone].number  
labels = [for l in var.issues[count.index].labels : github\_issue\_label.issues\_labels[l].name]  
}

provider “github” {  
owner = local.github\_owner  
}

---

<div class="post-metadata">

**Author:** ![elliefairholm](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/e/e0b2c6/32.png) [@elliefairholm](https://forum.devtalk.com/u/elliefairholm)\
**Post date:** [25 July 2024 15:26 UTC](https://forum.devtalk.com/t/engineering-elixir-applications-end-of-chapter-2-github-issues-labels/159474/5 "2024-07-25T15:26:31Z")

</div>

Thanks @SoldierCoder!

It looks like you’ve got a typo in the first issue in your issues list in .auto.tfvars:

{  
title = “Implement the Dockerfile’s builder stage”  
body = \<\<EOT  
The builder stage packages all the tools and compile-time dependencies for your  
application. It has to build the mix release that will be copied in the running  
stage.  
EOT  
labels = [“ **kind-infrastrcture** ”, “dockerfile”]  
milestone = “infrastructure”  
}

Rather than “kind-infrastrcture” it should say “_kind-infrastructure_”.

Let me know if that fixes the problem. Thanks!
