Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow (JSON formatted) input strings to be dictionaries #418

Closed
tma-unwire opened this issue Mar 30, 2022 · 1 comment
Closed

Allow (JSON formatted) input strings to be dictionaries #418

tma-unwire opened this issue Mar 30, 2022 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@tma-unwire
Copy link

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

When working with AWS resources you often have input parameters that are JSON formatted strings that contains the configuration for the resource. A typical example is the various IAM resources with roles and policies. Sometimes these even include Output from other resources.

In all cases, it can be nice - and a lot more readable - to inline the dictionary instead of having to use json.dumps(...), Output.apply(...) or even Output.all(...).apply(...)

A real world example

import json
from typing import Any, Mapping

import pulumi
import pulumi_random as random
from pulumi_aws import rds, ssm


def setup_rds_password_and_rotation(cluster: rds.Cluster, password: random.RandomPassword) -> None:
    def make_secret_string(data: Mapping[str, Any]) -> str:
        return json.dumps({
            'engine': 'mysql',
            'dbClusterIdentifier': 'rds-cluster',
            'host': data.get('endpoint'),
            'username': 'root',
            'password': data.get('password')
        })

    param = ssm.Parameter(
        '...',
        name='...',
        type='SecureString',
        data_type='text',
        value=pulumi.Output.all(endpoint=cluster.endpoint, password=password.result).apply(make_secret_string),
        description="Admin password used for RDS cluster",
    )

It would be so much nicer to be able to write this:

def setup_rds_password_and_rotation(cluster: rds.Cluster, password: random.RandomPassword) -> None:
    param = ssm.Parameter(
        '...',
        name='...',
        type='SecureString',
        data_type='text',
        value={
            'engine': 'mysql',
            'dbClusterIdentifier': 'rds-cluster',
            'host': cluster.endpoint,
            'username': 'root',
            'password': password.result
        },
        description="Admin password used for RDS cluster",
    )

As value is defined as a string, then Pulumi should automatically wait ion the result and jsonify the results..

Affected area/feature

Primarily in AWS, but something similar could also be useful in Kubernetes.

@guineveresaenger
Copy link

I am closing this so we can have the main discussion in pulumi/pulumi-aws#1883.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants