https://pulumi.com logo
#python
Title
# python
c

calm-doctor-76791

01/05/2024, 10:02 PM
Greetings! What would be a good way of getting a secret from a list ? Have a pulumi.*.yaml file like this:
Copy code
config:
  azure-native:location: eastus
  containerapp-environment:certificates:
    - name: my-web-cert
      password:
        secure: xxx
      value:
        secure: yyy
  containerapp-environment:certificates:
    - name: second-web-com
      password:
        secure: xxx
      value:
        secure: yyy
  containerapp-environment:env: dev
Where I would need to loop over the certificates, and grab the password and value and pass into a function creating the certificates;
Copy code
certificates = config.get_object("certificates")
..
if certificates:
    for certificate in certificates:
        name = certificate.get("name")
        password = x
        value = x

        cert = create_certificate(
            name=name,
            rg_name=rg,
            environment=managed_env,
            password=password,
            value=value,
            tags=tags,
            dependsOn=managed_env,
            location=location,
        )
h

hallowed-fireman-90476

01/05/2024, 10:16 PM
Try
Copy code
configs = pulumi.Config()
password = config.get_secret('containerapp-environment:certificates:password')
c

calm-doctor-76791

01/07/2024, 2:57 PM
Wouldn´t I somehow need to use get_secret to get the secret value? Also I need to loop over the certificates.
h

hallowed-fireman-90476

01/08/2024, 10:50 AM
Sorry i missed the secret part, updated my above snippet. Also is your intention to loop through certificates to get its values, then you can get value using
('containerapp-environment:certificates:password')
2 Views