RFC: Canonical Environment Configuration for Salesforce Projects #3476
Replies: 8 comments 1 reply
-
|
Great initiative! One of the most common use cases is not really mentioned, though: Different "unpackaged" source-components per environment, as part of a modularized deployment. Think about 10 packages and then environment specific overrides (named credentials, custom metadata settings, this stuff). I believe, a simple env name / src path mapping is enough. Let CI handle the authentication. Before I write too much, take a look at my open source project "sf-plugin" and the "manifest" implementation: https://github.com/j-schreiber/js-sf-cli-plugin It works incredibly well and powers my deployment pipelines for more than 2 years now. |
Beta Was this translation helpful? Give feedback.
-
|
I like the idea of environment specific context. Unfortunately I would create a more complicated layer of indirection (if you're familiar with CumulusCI's environments, very similar) where a given project could have a "prod" org but that is mapped locally to an alias or username in the CLI. It is too common for someone to build a required set of "use this alias and magic will happen" but what if I work on two separate projects that use the same environment naming and now I'm creating conflicts or juggling aliases per-project. My machine's aliases shouldn't have to align with a given projects preferences. Things like community projects and open source work would be much harder if you had to align with their context aside from your day-job. (hopefully they can all be creative enough to avoid this but not always) If you were to do env-specific files such as I'd also like to recommend that for the command behaviors, introduce the concept of a "protected" org and the CLI will crash if a destructive command is executed against that org (maybe with some way of registering custom commands on that list). Maybe I work somewhere that I need a login to the QA or UAT sandboxes but we still need them protected from changes from any source except CI/CD, now prod, QA, and UAT can all be protected. I personally definitely don't want a per-branch-to-env mapping, I'm sure some do but I don't want the CLI to have to be aware of my source tracking preferences and patterns. I can also say that my branch checkout doesn't usually influence which org I want to work with at any given moment. |
Beta Was this translation helpful? Give feedback.
-
|
When setting LOGIN IP RANGE by profile, one usually wants to configure systems with keeping environments contained. Prod <-> external Prod, UAT <-> external UAT, etc. However this is only possible manually (Not even BULK import). It means that values are not stored in source, and refreshing the org would require to manually re-write everything post-refresh. This shortcoming is getting worse because with integration with serverless microservices there is a plethora of potential IPs to enter manually. Thank you for the consideration |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the initiative, love it! The important thing we do with different environments is the change in named credentials, and sometimes custom metadata (like different cache times) across production and stage/integration/nft environments. We have a small script that copies these from a different directory, like We don't store prod named credentials at all, so it won't be deployed when code is pushed to production. Scratch orgs/dev sandboxes need to point to mocks, so that's a different named credential too at Another small thing we do is change the CORS whitelisting using a similar script (that copies it from another directory before deployment) as we don't want to add a Format Preferences - If it's possible, then a Security - Currently, we inject them via environment variables in our local script and secrets in our Github actions. We find they are alright. |
Beta Was this translation helpful? Give feedback.
-
|
Would environmental configurations allow for additional licenses in scratch orgs in the future? For example, only having one customer community plus license per scratch-org made it difficult to test certain scenarios for multiple external users. |
Beta Was this translation helpful? Give feedback.
-
|
I'd like to see different governance for branches. This isn't specifically your wheelhouse, but running different Code Analyzer rules based on the branch name would be good. |
Beta Was this translation helpful? Give feedback.
-
|
To the format question: It's easier to work with JSON/JS than YAML. Like I prefer Prettier config to be in JSON-style... and this would be better in the same style. YAML is just a pain with arrays, spaces, etc. The line breaks matter, whereas JSON ignores line breaks... and so on. |
Beta Was this translation helpful? Give feedback.
-
|
What’s missing? Are there other environment-specific settings you find yourself constantly re-coding in every project? What have you built? If you’ve already created a custom solution for this (ex: a config/environments.json file or custom CLI plugins), what worked? What didn't? Format Preferences - How would you prefer to manage this? (ex: a single sfdx-environments.json, a /config/environments/ directory with YAML files, TextProto representation, etc.) I'd imagine a place in Setup where, when granted the permissions, a person can view all of the orgs related to the production org the sandbox or scratch org is part of. From there, orgs can be designated certain properties (e.g., QA, UAT, prod data for full copy sandboxes, etc.). Then people can build pipelines around fetching those properties for org connection details when doing deployments and what not. This would also help other vendors that are building deployment pipelines (e.g., Harness, Gearset, Copado, etc.). What different commands do with orgs that have certain properties could be defined in source control (e.g., run all org tests, deploy this extra thing, etc.). I think if a solution is designed without the non-dx community in mind then it could cause more annoyances down the road 😄 Security - How are you currently handling the hand-off between source-controlled config and sensitive secrets? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
Today, managing the lifecycle of a Salesforce project across multiple environments (QA, UAT, Prod) requires a significant amount of bespoke code and configuration. Developers and DevOps engineers often spend hours writing custom bash scripts, configuring environment variables and secrets in their DevOps pipeline runners, and managing
.forceignoreto ensure that each of the environments acts properly.Because there is no canonical way to define an environment's identity and behavior in source, the IDE (VS Code) and the CLI often don't "know" which rules apply to the org you are currently authorized against.
The lack of environment-aware tooling can create a real operational risk. As mentioned in Discussion #2189, the unification of commands like
sf project deploystart means that a command intended for a Scratch Org can easily be run against Production if a developer forgets they switched their default org. We’ve lost some of the natural guardrails that existed when "push" and "deploy" were separate concepts.Vision
We are exploring a standardized way to define environment configurations within your Salesforce DX projects. The goal is to have teams define their environment configurations in source and have it drive dynamic environment-specific behavior in both the IDE and CI/CD pipelines.
What could this include? We are considering including the following capabilities in this standard representation:
userName,instanceUrl, and injected secrets (ex:DEV_KEY_SECRET) to simplify headless auth for CI and CD jobs and anything else that's helpful.RunRelevantTests, while "Production" requiresRunLocalTests..forceignore: Ability to ignore certain metadata types specifically for one environment but not others.We want your feedback!
Before we lock in a specification, we want to hear from the community:
config/environments.jsonfile or custom CLI plugins), what worked? What didn't?sfdx-environments.json, a/config/environments/directory with YAML files, TextProto representation, etc.)Beta Was this translation helpful? Give feedback.
All reactions