mammoth-airline-60094
12/04/2024, 6:32 PMpulumi preview
but fail on a pulumi up
)? e,g by allowing AWSS3ReadOnlyAccess on a bucket. Or would this run the infra update but just fail to update the state?
• finally is there an agreed upon best practice of repo structure (and or component design structure) for Pulumi projects?
• is it possible to use the automationAPI with the pulumi k8s operator?
If I have missed something painfully obvious in the docs, please feel free to refer me to the docs 🙂modern-zebra-45309
12/04/2024, 6:59 PMmodern-zebra-45309
12/04/2024, 7:11 PM• secondly is it possible to allow users to only read a state (therefore allow for aAs a general rule, you should not rely on Pulumi to protect your infrastructure this way. You'll have to scope your IAM roles and policies so that only authorized users can modify the infrastructure. It is possible to runbut fail on apulumi preview
)? e,g by allowing AWSS3ReadOnlyAccess on a bucket. Or would this run the infra update but just fail to update the state?pulumi up
pulumi preview
with infrastructure read permissions. To get a meaningful result, you'll want to refresh your state first (either through pulumi refresh
or by running pulumi preview --refresh
) so that it reflects the current state of your deployed resources. This requires write permissions for the state file: Pulumi will go through the state as it's currently recorded in the state file and update all resource entries so that they match the resource's actual state.modern-zebra-45309
12/04/2024, 7:16 PMprograms
and a components
(or lib
) directory, or a directory per program. If you just have a few programs, you can also just keep them all in the main folder as in the examples repo.
Edit: Also check out this recent thread for more ideas and considerations.modern-zebra-45309
12/04/2024, 7:21 PMpulumi up
from your terminal you'll make these calls from your application code. But the Pulumi programs and everything else stays the same, you can use the same Pulumi programs via the Automation API and with the Pulumi CLI.
If you look at the source code for the API, you'll see that it calls out to the Pulumi CLI: https://github.com/pulumi/pulumi/blob/master/sdk/python/lib/pulumi/automation/_cmd.py#L184
The Automation API is helpful if you want to create your own CLI or management application for your infrastructure.mammoth-airline-60094
12/05/2024, 12:20 PMpulumi refresh
I assume if we mandate that only changes in IAC is canonical then this command is not required before a pulumi preview
?
> As a general rule, you should not rely on Pulumi to protect your infrastructure this way.
True, but I guess its more about failing fast, if the user attempts to deploy a stack, and has permissions to read state, no permissions to edit infra, and no permissions to write state, then I would hope it fails at the point after comparing changes before attempting to make changes (vs getting a 100 permission denied errors)modern-zebra-45309
12/06/2024, 7:07 PMpulumi refresh
> I assume if we mandate that only changes in IAC is canonical then this command is not required before a pulumi preview
?
You'll always want to refresh, even if only to verify that indeed everything is as you left it. In my experience, there's always something disappearing, being re-configured by another service, something auto-restarted to a different configuration... (There's a reason the controller pattern for infrastructure is a thing.)
If you want to be sure that your pulumi up
goes through and your infrastructure will be in the state you defined in your Pulumi program, you should run a pulumi refresh
right before.modern-zebra-45309
12/06/2024, 7:10 PM> As a general rule, you should not rely on Pulumi to protect your infrastructure this way.
True, but I guess its more about failing fast, if the user attempts to deploy a stack, and has permissions to read state, no permissions to edit infra, and no permissions to write state, then I would hope it fails at the point after comparing changes before attempting to make changes (vs getting a 100 permission denied errors)This is obviously a case of "it depends" but I would still say that you should not manage this through read/write permissions on Pulumi state files. I can see a good case for someone not being allowed to change the infrastructure but no good case for someone who's allowed to see the infrastructure not being allowed to update the Pulumi state to the current infrastructure state.
modern-zebra-45309
12/06/2024, 7:16 PMarn:aws:s3:::_amzn-s3-demo-bucket1_/*
or arn:aws:s3:::_amzn-s3-demo-bucket1_/my-project-path/*
in the policy. But it depends on how you generally go about managing access for roles/users, of course and I've also encountered situations where it was easier to use separate buckets for separate users/entities.
> Can work within this pattern, just wanted to verify if is was possible to use different backends for different environments (where the environment is made up of inter-linked stacks - implementations of projects)
You cannot have stack references across backends (as far as I know and understand the architecture) but you can have stack references across projects.
Further food for thought: If you have one Pulumi project that contains both preprod and prod stacks, they'll necessarily have to have different names (e.g., db-preprod
and db-prod
) and nobody gets the idea to give the stacks the same name and someone just typing away pulumi stack select db
and pulumi up
is accidentally updating prod.modern-zebra-45309
12/06/2024, 7:40 PMmammoth-airline-60094
12/06/2024, 11:48 PM