https://pulumi.com logo
#automation-api
Title
# automation-api
l

limited-rainbow-51650

04/01/2021, 7:30 PM
Hello, I’m using the Automation API to implement an integration for Pulumi with Concourse CI: https://github.com/ringods/pulumi-resource/ Any resource (Concourse term) you use in a build pipeline is configured in YAML. You have the identification of the resource and some parameters. For example, to apply a Pulumi stack, this is the snippet I intend to use:
Copy code
resource_types:
- name: pulumi
  type: docker-image
  source:
    repository: <http://ghcr.io/ringods/pulumi-resource|ghcr.io/ringods/pulumi-resource>
    tag: v0.0.6

resources:
  - name: myinfracode
    type: pulumi
    source:
      organization: companyname
      project: network
      stack: staging
      token: pul-XXXXXXXXXXXXXXXXX

jobs:
  - name: nextstack
    plan:
      - task: build-artifact
        ...
      - put: myinfracode
        params:
          aws:region: eu-west-1
          network:cidr: 'x.x.x.x'
In my Concourse resource, I want to allow anything in the
params
section above which is valid Pulumi stack config (nested et all). In my resource implementation, I get this passed as JSON though:
Copy code
{
  "source": {
    "organization": "company",
    "project": "network",
    "stack": "staging",
    "token": "pul-XXXXXXXXXXXXXXXXX"
  },
  "params": {
    "aws:region": "eu-west-1",
    "network:cidr": "x.x.x.x"
  }
}
The
source
section is specific to Pulumi, but the
params
is the JSON equivalent of what I configured as YAML in my pipeline. Is there any function in the Pulumi code base that can Unmarshal this to a Pulumi type representing this Config?
p

plain-quill-22197

04/02/2021, 8:08 AM
If you use structured config, you can assign the whole json to a particular config key, sending the JSON object as string