-
Notifications
You must be signed in to change notification settings - Fork 7
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Environment Resource #271
Conversation
f964e07
to
8219f71
Compare
"yaml": { | ||
"description": "Environment's yaml file.", | ||
"$ref": "pulumi.json#/Asset" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should make absolutely certain that assets work with output properties. Not 100% sure about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed it works with output using Random and below snippet of code:
var random = new RandomString("rand", new RandomStringArgs
{
Length = 5,
Special = false,
});
Output<AssetOrArchive> asset = random.Result.Apply(res => {
String yaml = """
imports:
- dev-stacks
values:
aws:
secrets:
fn::open::aws-secrets:
region: us-west-2
login: ${aws.creds}
get:
allSecrets:
secretId: iaro-dev-stack/pulumi-service
secrets:
fn::fromJSON: ${aws.secrets.allSecrets}
pulumiConfig:
gitHubOAuthID: ${secrets.gitHubOAuthID}
gitHubOAuthSecret: ${secrets.gitHubOAuthSecret}
randomString:
""" + res;
AssetOrArchive asset = new StringAsset(yaml);
return asset;
}
);
var environ = new Pulumi.PulumiService.Environment(
"Iaro's environment",
new EnvironmentArgs {
Organization = "IaroslavTitov",
Name = "IaroEnv",
Yaml = asset
}
);
When I go to see the environment in console it has a random blurb zbhrh
and the same in Random's resource properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I should clarify--I meant that I'm not sure that the output property Environment.Yaml
will work with assets. I'd try passing the Yaml
output of one environment to the Yaml
input of another.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, gotcha, didn't understand properly
Confirmed that this works, creating 2 environments with identical yaml:
var environ = new Pulumi.PulumiService.Environment(
"Iaro's environment",
new EnvironmentArgs {
Organization = "IaroslavTitov",
Name = "IaroEnv",
Yaml = asset
}
);
var environ2 = new Pulumi.PulumiService.Environment(
"Iaro's environment 2",
new EnvironmentArgs {
Organization = "IaroslavTitov",
Name = "IaroEnv2",
Yaml = environ.Yaml.Apply(yaml => yaml)
}
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW @IaroslavTitov you shouldn't have to do this:
Yaml = environ.Yaml.Apply(yaml => yaml)
It can just be:
Yaml = environ.Yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, makes sense, got stuck in the Apply mindset
61f3ff3
to
69a85eb
Compare
High-level question: If my environment definition contains secrets, are those stored in plaintext unless the entire environment definition is marked secret? For example, in the following program, will const env = new Environment("env", { yaml: `{ values: { foo: { fn::secret: hunter2 } } }` }); |
Tried this, shows up as plaintext in the Resources tab. (In Environments, shows up as ciphertext) Unfortunately, I don't think we can avoid storing it as plaintext, in order for import to work, this is the same issue as with Deployment Settings. We can add some frontend logic to *** them out maybe? Still obv wouldn't actually hide the secrets, just visually. |
So users can manually mark the environment def as secret in their Pulumi program: const env = new Environment("env", { yaml: pulumi.secret(`{ values: { foo: { fn::secret: hunter2 } } }`) }); That will encrypt the YAML in the statefile. We might also be able to do this automatically as part of
Yeah we need to chat more about our approach to diffing with secrets. I think that we have several options here, but all of them will involve tradeoffs. |
Ooh, I did not think of that, I think that shouldn't be hard, I'll look into it and update the PR.
Yep, that's the purpose of that doc, to get a conversation going |
ac2134f
to
473b0bf
Compare
Updated to force yaml to always be a secret property. I then went down the rabbit hole trying to solve noisy diff when user has extra spaces in the yaml, which ESC then removes and causes diff. Sadly, found no way of eliminating this issue with secrets, as Diff receives only hash of a secret Asset, not full text and this can only be compared exactly, and not partially. It is a rare chance anyone will hit that issue though (I totally accidentally stumbled into it), so I think it's fine. |
@IaroslavTitov can you resolve the conflicts please? |
Done! |
Summary
Testing
Tested in dev stack using below Pulumi Program (Dotnet SDK), confirmed that things like imports, opening environment work as expected.