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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deck support placeholder replace #191

Closed
cello86 opened this issue Jul 20, 2020 · 9 comments · Fixed by #286
Closed

Deck support placeholder replace #191

cello86 opened this issue Jul 20, 2020 · 9 comments · Fixed by #286
Assignees

Comments

@cello86
Copy link

cello86 commented Jul 20, 2020

Hi,
is it possible to apply a sort of placeholder substitution into deck sync operation to support the multi environment configuration via single branch of SCM like git?

Regards,
Marcello

@antodr
Copy link

antodr commented Jul 20, 2020

Hello @cello86 ,
I usually do these substitutions during the build step

@cello86
Copy link
Author

cello86 commented Jul 20, 2020

HI @Zaragon-AQ,
Actually we have implemented a pipeline that downloads the YAML file config from our SCM and we replace the placeholders with replace ansible module.

This work fine but we would understand if we have to adjust the files before the release via deck sync or there are some other quick steps like env variables to perform the same operation.

Thanks,
Marcello

@dowster
Copy link

dowster commented Jul 20, 2020

Seconding the approach of doing this in the build step. We use YTT https://get-ytt.io/ to do string replacement along with replacement of entire YAML structures based off environment specific properties files that get fed in for each of our environments.

@hbagdi
Copy link
Member

hbagdi commented Jul 21, 2020

Up until this point, I've been against adding such a feature into decK because templating is a whole another problem that decK will never be able to solve in a way that makes even 80% of users happy. And hence, I've been advising all users to use solutions like YTT or j2, bring-your-own-templating-engine.

Having said that, there are more and more users who are requesting this feature and I'm now reconsider my position on this. Adding some basic templating into decK could help many users. But before we do so, we need some examples from the community on how people are templating their YAMLs today.

Would all users in this thread mind sharing their solutions with some code and samples? That should help us understand the expectations and come up with a design that works well for everyone.

Cheers!

@cello86
Copy link
Author

cello86 commented Jul 22, 2020

Hi @hbagdi,
in our case we don't use an advanced templating, but we are only replace some placeholders as reported below:

_format_version: "1.1"
  | _workspace: $WORKSPACE
  | services:
  | - connect_timeout: 60000
  | host: $KONG_LOCALHOST_BACKEND
  | name: kong-localinstance
  | path: /
  | port: 80
  | protocol: http
  | read_timeout: 60000
  | retries: 5
  | write_timeout: 60000
  | routes:
  | - hosts:
  | - $KONG_LOCALHOST_BACKEND
  | name: kong-internal-probe
  | methods:
  | - GET
  | paths:
  | - /kong-probe.html
  | preserve_host: false
  | protocols:
  | - http
  | regex_priority: 0
  | strip_path: false
  | plugins:
  | - name: request-termination
  | config:
  | body: null
  | content_type: null
  | message: Kong localhost probe
  | status_code: 200
  | enabled: true
  run_on: first

Marcello

@cwurm
Copy link
Contributor

cwurm commented Aug 5, 2020

To me, the most basic requirement would to be to avoid putting secrets and passwords into deck files. Unfortunately, I have seen it happen several times that AWS secrets were exposed that were used to configure the Lambda plugin.

Maybe a straightforward implementation would be to use bash-style variable replacement, e.g.:

plugins:
- name: aws-lambda
  config:
    aws_secret: ${AWS_SECRET}

decK already uses Viper which can read environment variables, config files, and even values from etcd and Consul - so it would mostly be about inserting those in the right places when reading the state.

@hbagdi
Copy link
Member

hbagdi commented Aug 18, 2020

Thanks for the input here. I've something concrete in my mind to get to the feature state. Here is the summary:

  • The templating language will look like ${{ env "AWS_SECRET" }}. We will expand the template functions in future to include injection of values from other sources.
  • deck render or a similar named CLI command which can render a state file based on the inputs (env vars, reading from vault etc) you give it

@hbagdi hbagdi self-assigned this Mar 7, 2021
hbagdi added a commit that referenced this issue Mar 7, 2021
Introducing support for envirment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191
@hbagdi
Copy link
Member

hbagdi commented Mar 7, 2021

Please take a look at this PR for this feature: #286

@stale
Copy link

stale bot commented Mar 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Will be closed unless advocated for within 7 days label Mar 21, 2021
@stale stale bot closed this as completed Mar 28, 2021
@hbagdi hbagdi reopened this Mar 29, 2021
@stale stale bot removed the stale Will be closed unless advocated for within 7 days label Mar 29, 2021
hbagdi added a commit that referenced this issue Apr 8, 2021
Introducing support for envirment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191
hbagdi added a commit that referenced this issue Apr 8, 2021
Introducing support for envirment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191
hbagdi added a commit that referenced this issue Apr 13, 2021
Introducing support for envirment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191
hbagdi added a commit that referenced this issue Apr 14, 2021
Introducing support for envirment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191
hbagdi added a commit that referenced this issue Apr 15, 2021
Introducing support for environment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191

Co-authored-by: Michał Flendrich <michal@flendrich.pro>
rainest pushed a commit that referenced this issue Apr 21, 2021
Introducing support for environment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191

Co-authored-by: Michał Flendrich <michal@flendrich.pro>
AntoineJac pushed a commit that referenced this issue Jan 23, 2024
Introducing support for environment variable substitution in state files.
This is primarily intended for injecting sensitive data at runtime.

Fix #191

Co-authored-by: Michał Flendrich <michal@flendrich.pro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants