tofu-controller icon indicating copy to clipboard operation
tofu-controller copied to clipboard

Consuming an output which is a map

Open Smana opened this issue 1 year ago • 1 comments

Hello,

I'd like to retrieve the domain_name and the zone_id from a hosted zone created with the controller. However I'm struggling getting the proper format. Actually when I use that

  writeOutputsToSecret:
    name: route53-cloud-hostedzone
    outputs:
      - route53_zone_name:domain_name
      - route53_zone_zone_id:zone_id

I don't get the expected string format

apiVersion: v1                                                                                                                                                                                                                                
data:                                                                                                                                                                                                                                         
  domain_name: ewogICAgICAiY2xvdWQub2dlbmtpLmlvIjogImNsb3VkLm9nZW5raS5pbyIKICAgIH0=                                                                                                                                                           
...                                                                                                                         
kind: Secret                                                                                                                                                                                                                                  
metadata:                                                                                                                                                                                                                                     
  name: route53-cloud-hostedzone                                                                                                                                                                                                              
  namespace: flux-system
{
      "my.domain.tld": "my.domain.tld"
    }

From my understanding I should parse the output within the resource that consumes the secret but I don't know how to proceed.

the module expects the string domain_name and zone_id

kind: Terraform
metadata:
  name: acm-cloud
spec:
  approvePlan: auto
  destroyResourcesOnDeletion: false
  interval: 8m
  path: ./
  sourceRef:
    kind: GitRepository
    name: terraform-aws-acm
    namespace: flux-system
  vars:
    - name: subject_alternative_names
      value:
        - "*.my.domain.tld"
    - name: wait_for_validation
      value: true
    - name: tags
      value:
        Name: "my.domain.tld"
  varsFrom:
    - kind: Secret
      name: route53-cloud-hostedzone

========

User Story:

As a user of Terraform Controller, I'd like to retrieve and format the domain_name and zone_id from a hosted zone created with the controller, so that I can use them as input for other resources without having to create custom modules.

Acceptance Criteria:

  • [ ] The output format of the domain_name and the zone_id from the hosted zone should be a string.
  • [ ] The user should be able to use the domain_name and zone_id values as input variables for other resources.
  • [ ] The solution should support consuming output variables from community modules without requiring custom modifications.

Smana avatar Jun 02 '23 18:06 Smana