Skip to content

Commit 05e4e27

Browse files
authored
Merge pull request #52 from defang-io/lio-sensitive-env
support sensitive env vars
2 parents 2c0bc89 + 8325610 commit 05e4e27

File tree

10 files changed

+217
-66
lines changed

10 files changed

+217
-66
lines changed

blog/2024-03-28-slackbot-sample.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Before we dive into the details, let's make sure you have everything you need to
1313

1414
1. **Install Defang CLI:** Simplify your deployment process by installing the Defang CLI tool. Follow the instructions [here](https://docs.defang.io/docs/getting-started/installing) to get it up and running quickly.
1515

16-
2. **Slack API Token:** Create a Slack App at https://api.slack.com/apps, granting it the necessary permissions, including the bot `chat:write` scope.
16+
2. **Slack API Token:** Create a Slack App at https://api.slack.com/apps, granting it the necessary permissions, including the bot `chat:write` scope.
1717
![screenshot of the slack admin UI showing the bot scopes](/img/slackbot-sample/scopes.png)
1818

1919
3. **Install the app in your workspace:** You'll need to install the app in your workspace for it to work. Click the "Install to Workspace" button in the Slack admin UI to do this. Mine says "Reinstall" because I've already installed it.
@@ -36,12 +36,12 @@ cd defang/samples/golang/slackbot
3636

3737
Now that we have everything set up, let's dive into the deployment process. Follow these steps to deploy your Slackbot effortlessly:
3838

39-
1. **Set Up Secrets:** Prioritize security by configuring environment variables as secrets. Use the Defang CLI's `defang secret set` command to set the `SLACK_TOKEN` and `SLACK_CHANNEL_ID` secrets.
39+
1. **Set Up Secrets:** Prioritize security by configuring environment variables as secrets. Use the Defang CLI's `defang config set` command to set the `SLACK_TOKEN` and `SLACK_CHANNEL_ID` secrets.
4040
Replace `your_slack_token` and `your_slack_channel_id` with the respective values:
4141

4242
```bash
43-
defang secret set --name SLACK_TOKEN --value your_slack_token
44-
defang secret set --name SLACK_CHANNEL_ID --value your_slack_channel_id
43+
defang config set --name SLACK_TOKEN --value your_slack_token
44+
defang config set --name SLACK_CHANNEL_ID --value your_slack_channel_id
4545
```
4646

4747
2. **Deploy the Slackbot:** Use the Defang CLI's `defang compose up` command to deploy.

docs/concepts/compose.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ One thing to keep in mind is that, at the time of this writing, Defang identifie
2020

2121
## Configuration
2222

23-
If you have a service that depends on a secret like an api key, you can set that [secret](./secrets.md) using the CLI:
23+
If you have a service that depends on a secret like an api key, you can set that [secret](./configuration.md) using the CLI:
2424

2525
```
26-
defang secret set --name MY_API_KEY
26+
defang config set --name MY_API_KEY
2727
```
2828

2929
and then connect it to the service by specifying it in the `compose.yaml`:
@@ -40,5 +40,5 @@ secrets:
4040
```
4141
4242
:::info Configuration & Secrets
43-
Read more about configuration in the [configuration page](./configuration.md) and about secrets in the [secrets page](./secrets.md).
43+
Read more about configuration in the [configuration page](./configuration.md) and about secrets in the [secrets page](./configuration.md).
4444
:::

docs/concepts/configuration.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
---
22
title: Configuration
3-
description: Configuring your Defang application.
3+
description: Configuring your Defang application, including sensitive config values like API keys, passwords, and other credentials.
44
sidebar_position: 225
55
---
66

77
# Configuration
88

99
Defang allows you to configure your application using environment variables. You can set environment variables in your [`compose.yaml` file](./compose.md), or in your [Pulumi program](./pulumi.md). Using Pulumi gives you the advantage of being able to manage your environment variables across different environments using Pulumi stacks.
1010

11-
You can also use [secrets](./secrets.md) to store sensitive information like API keys and database passwords.
12-
1311
:::tip Sample
1412
You can find a sample of how to set environment variables with Pulumi [here](https://github.com/defang-io/defang/tree/main/samples/nodejs/remix-aiven-postgres).
15-
:::
13+
:::
14+
15+
# Sensitive Config aka Secrets
16+
17+
The Defang CLI allows you to securely store sensitive information such as API keys, passwords, and other credentials.
18+
19+
You can use sensitive config by specifying them in the `environment` section of a service in a `compose.yaml` file without any value, or by specifying an environment key with a `null` value in your Pulumi code.
20+
21+
```ts
22+
services:
23+
service1:
24+
image: image1:latest
25+
environment:
26+
- API_KEY
27+
```
28+
29+
Use the `defang config` command of the Defang CLI to manage the values.
30+
31+
## Connecting Services
32+
33+
If you have created a service before a secret you can connect it by running the `defang compose start` command if using the [`defang compose` workflow](./compose.md). If you are using the [Pulumi-based workflow](./pulumi.md) you will need to redeploy using Pulumi.
34+
35+
:::tip Sample
36+
You can find a sample of how to set sensitive config values [here](https://github.com/defang-io/defang/tree/main/samples/nodejs/ChatGPT%20API).
37+
:::
38+
39+
## Providers
40+
41+
Here are the different ways sensitive config values are stored depending on the provider you are using:
42+
43+
* [AWS](../providers/aws.md#secrets)

docs/concepts/secrets.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ secrets:
132132
```
133133

134134
### "unsupported secret …: not marked external:true"
135-
- This message is displayed when you run `defang compose up` and the Compose file declares a `secret` that is not marked `external:true`. Defang only supports external secrets, managed by the `defang secret` command. To silence the warning, mark the secret as `external:true` in the top-level `secrets` section:
135+
- This message is displayed when you run `defang compose up` and the Compose file declares a `secret` that is not marked `external:true`. Defang only supports external secrets, managed by the `defang config` command. To silence the warning, mark the secret as `external:true` in the top-level `secrets` section:
136136
```
137137
138138
secrets:

docs/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Defang provides a streamlined experience to develop, deploy, observe, and update
2525
- Automated [Dockerfile builds](./concepts/deployments.md)
2626
- Support for [pre-built Docker containers](./tutorials/deploy-container-using-the-cli.mdx), from public or private image registries
2727
- Ability to express your project configuration using a [Docker Compose YAML](./concepts/compose.md) file
28-
- Ability to manage encrypted [secrets](./concepts/secrets.md) and [configuration](./concepts/configuration.md)
28+
- Ability to manage [encrypted configuration values](./concepts/configuration.md)
2929
- Pre-configured environments with built-in [security](./concepts/security.md), [networking](./concepts/networking.mdx), and [observability](./concepts/observability.md)
3030
- [One-command deployments](./getting-started/installing.md)
3131
- Support for [GPUs](./concepts/resources.md)

docs/providers/aws.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you have the aws CLI installed, you should be able to successfully run `aws s
2121
:::
2222

2323
:::warning
24-
The Defang CLI does not depend on the AWS CLI. It uses the [AWS SDK for Go](https://aws.amazon.com/sdk-for-go/) to interact with your AWS account. In most cases, if you can run the `aws sts get-caller-identity` from the tip above, you should be good to go. However, due to a difference between the AWS CLI and the AWS SDK for Go, there is at least one case where they behave differently: if you are using `aws sso login` and have clashing profiles in your `.aws/config` and `.aws/credentials` files, the AWS CLI will prioritize SSO profiles and caches over regular profiles, but the AWS SDK for Go will prioritize the credentials file, and it may fail.
24+
The Defang CLI does not depend on the AWS CLI. It uses the [AWS SDK for Go](https://aws.amazon.com/sdk-for-go/) to interact with your AWS account. In most cases, if you can run the `aws sts get-caller-identity` from the tip above, you should be good to go. However, due to a difference between the AWS CLI and the AWS SDK for Go, there is at least one case where they behave differently: if you are using `aws sso login` and have clashing profiles in your `.aws/config` and `.aws/credentials` files, the AWS CLI will prioritize SSO profiles and caches over regular profiles, but the AWS SDK for Go will prioritize the credentials file, and it may fail.
2525
:::
2626

2727
## Region
@@ -34,7 +34,7 @@ Defang uses resources that are native to the cloud provider you are using. The f
3434

3535
### Secrets
3636

37-
Defang allows you to configure your services with secrets. Secrets are stored in AWS Systems Manager Parameter Store, and are encrypted.
37+
Defang allows you to configure your services with sensitive config values. Sensitive values are stored in AWS Systems Manager Parameter Store, and are encrypted.
3838

3939
### Deployment
4040

0 commit comments

Comments
 (0)