You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -35,28 +35,68 @@ Sandbox environments include additional features for managing secrets, deploying
35
35
## Secure secrets in your sandbox
36
36
37
37
<Calloutinfo>
38
+
38
39
Secrets set in a sandbox do not show up in the Amplify Console. You can view them in the AWS Systems Manager (SSM) Parameter Store console.
40
+
39
41
</Callout>
40
42
41
-
Amplify Gen 2 offers secure secret storage to manage sensitive data like API keys and database credentials. Secrets are similar to environment variables, but they are encrypted AWS Systems Manager Parameter Store key value pairs. Secrets are stored in AWS Parameter Store with the following naming convention: `/amplify/<package.json#name>/<sandbox-name>/<key-name>`.
43
+
Amplify Gen 2 offers secure secret storage to manage sensitive data like API keys and database credentials. Secrets are similar to environment variables, but they are encrypted AWS Systems Manager Parameter Store key value pairs. Secrets are stored in AWS Parameter Store under the `/amplify` prefix.
42
44
43
45
### Set secrets
44
46
45
-
You can add secrets while running your cloud sandbox with the following command:
47
+
You can add secrets to your sandbox environment using the following command:
46
48
47
-
```bash title="Terminal" showLineNumbers={false}
49
+
```bash
48
50
npx amplify sandbox secret set foo
49
51
? Enter secret value: ###
50
52
Done!
51
53
52
-
>npx amplify sandbox secret set bar
54
+
npx amplify sandbox secret set bar
53
55
? Enter secret value: ###
54
56
Done!
55
57
```
56
58
57
-
### Access secrets
59
+
After these commands, your sandbox will have two secrets named `foo` and `bar`.
60
+
61
+
### List secrets
62
+
63
+
You can list all of the secret names available in your sandbox environment with the following command:
64
+
65
+
```bash
66
+
npx amplify sandbox secret list
67
+
- foo
68
+
- bar
69
+
```
70
+
71
+
### Retrieve a secret
72
+
73
+
<Calloutwarning>
74
+
75
+
**Note:** This will print a secret value in plain text to the terminal. Do not use this command anywhere that terminal logs may be stored (such as CI/CD jobs).
76
+
77
+
</Callout>
78
+
79
+
To show the value of a secret, run the following command.
80
+
81
+
```bash
82
+
npx amplify sandbox secret get foo
83
+
name: foo
84
+
version: 1
85
+
value: abc123
86
+
lastUpdated: Mon Nov 13 2023 22:19:12 GMT-0800 (Pacific Standard Time)
87
+
```
88
+
89
+
### Remove secrets
90
+
91
+
To remove a secret from from the sandbox, run the following command in your terminal:
92
+
93
+
```bash
94
+
npx amplify sandbox secret remove foo
95
+
```
96
+
97
+
### Reference secrets
58
98
59
-
Once you have set a secret, you can access the values in code by calling the `secret()` function. The following example shows how to set up social sign-in with authentication in your app. Depending on your environment, Amplify will automatically load the correct secret value with no extra configuration.
99
+
Once you have set a secret, you can reference the secret in your backend definition using the `secret()` function. The following example shows how to set up social sign-in with authentication in your app. Depending on your environment, Amplify will automatically load the correct secret value.
The `secret()` function does NOT retrieve the value of the secret. It places a reference to the secret value in the backend definition. The secret value is only resolved during deployment of your backend.
80
120
81
-
To get the value of a secret from the cloud, run the following command in your terminal:
82
-
83
-
```bash title="Terminal" showLineNumbers={false}
84
-
npx amplify sandbox secret get foo
85
-
name: foo
86
-
version: 1
87
-
value: 123
88
-
lastUpdated: Mon Nov 13 2023 22:19:12 GMT-0800 (Pacific Standard Time)
89
-
```
121
+
The `secret()` function can only be used in specific places in your backend definition such as [configuring auth providers](/gen2/build-a-backend/auth/add-social-provider/#configure-social-sign-in-backend) and [granting function secret access](/gen2/build-a-backend/functions/#secret-access).
90
122
91
-
### Remove secrets
123
+
<Calloutinfo>
92
124
93
-
To remove a secret from the cloud, run the following command in your terminal:
125
+
To deploy a backend that uses `secret()` references via Amplify hosting, the secret values must be [configured for the Amplify app or branch](/gen2/deploy-and-host/fullstack-branching/secrets-and-vars)
94
126
95
-
```bash title="Terminal" showLineNumbers={false}
96
-
npx amplify sandbox secret remove foo
97
-
```
127
+
</Callout>
98
128
99
-
###Work with multiple AWS profiles
129
+
## Work with multiple AWS profiles
100
130
101
-
Sometimes you might have multiple AWS profiles set up locally. To run `amplify sandbox secret` commands, use the `--profile` flag to deploy to a specific profile. For example, let's say you have two AWS profiles set up locally—`default` and `work`. To add secrets to the `work` profile, run the following command in your terminal:
131
+
Sometimes you might have multiple AWS profiles set up locally. To run `amplify sandbox secret` commands, use the `--profile` flag to deploy to a specific profile. For example, let's say you have two AWS profiles set up locally—`default` and `work`. To add secrets to the sandbox in the `work` profile, run the following command in your terminal:
102
132
103
-
```bash title="Terminal" showLineNumbers={false}
133
+
```bash
104
134
npx amplify sandbox secret set foo --profile work
105
135
```
106
136
107
-
## Multiple sandboxes per app
137
+
## Work with multiple named sandboxes
108
138
109
139
<Calloutinfo>
110
-
Provisioning multiple sandboxes per app is possible but not recommended because managing multiple ephemeral environments for a single app introduces complexity. With multiple sandboxes, it can be difficult to keep track of what code version or configuration is deployed where. Sticking to a single ephemeral sandbox per app keeps your workflows simple and straightforward.
111
-
</Callout>
112
140
113
-
You can create multiple cloud sandbox environments for each app if you want to keep persistent sandbox environments up and running to test against. First, run the following command in the terminal:
141
+
Provisioning multiple sandboxes per app is possible but not recommended because managing multiple ephemeral environments for a single developer introduces complexity. With multiple sandboxes, it can be difficult to keep track of what code version or configuration is deployed where. Sticking to a single sandbox per developer keeps your workflows simpler.
114
142
115
-
```bash title="Terminal" showLineNumbers={false}
116
-
npx amplify sandbox --name s1
117
-
```
143
+
</Callout>
118
144
119
-
Once the deployment completes, exit sandbox `s1` and run the following command in the terminal:
145
+
You can create multiple sandboxes if you want to have different features or test environments available in different sandboxes. By default, your sandbox is named based on the local machine username. To override this name, use the `--identifier` option:
120
146
121
-
```bash title="Terminal" showLineNumbers={false}
122
-
npx amplify sandbox --name s2
147
+
```bash
148
+
npx amplify sandbox --identifier feature1sandbox
123
149
```
124
150
125
-
After successful deployment, sandboxes `s1` and `s2` will be ready. Pick sandbox `s1` or `s2` to activate. You can switch between them but only one can be running at a time.
126
-
127
-
## Generate client config
151
+
This will start a sandbox named `feature1sandbox`.
128
152
129
-
The client config (e.g. `amplifyconfiguration.json` file for Web) contains the configuration strings for interacting with AWS resources specific to an environment. The Amplify client libraries need the client config file in order to use the library APIs to connect to backend resources. By default, the cloud sandbox generates the client configuration file at the root of the project (such as `@/amplifyconfiguration.json`). If you want to place the file at a different path you can use the following command template:
153
+
Once the deployment completes, exit sandbox and run the following command in the terminal:
After successful deployment, you will have two sandboxes `feature1sandbox` and `feature2sandbox`. You can switch between them but only one can be running at a time.
136
160
137
-
For Web and React Native, generating the client in the root of the project would work, but all the other platforms have specific directories to target.
When working with multiple sandboxes, secrets must be configured for each one. All of the `sandbox secret` commands accept the `--identifier` argument to manage secrets for named sandboxes. For example, to add a secret to `feature1sandbox`, use:
The client config, or `amplifyconfiguration.json` file, contains the configuration strings for interacting with AWS resources specific to an environment. The Amplify client libraries need the client config in order to use the library APIs to connect to backend resources. By default, the cloud sandbox generates the client configuration file at the root of the project (such as `@/amplifyconfiguration.json`). If you want to place the file at a different path (such as for a monorepo or Android app), run the following command in the terminal:
Once the sandbox environment is running, you would also generate the configuration files for your application. However, Xcode won't be able to recognize them. For recognizing the files, you need to drag and drop the generated files to your project.
177
+
Alternatively, if you want to generate the config for a branch environment to test against, run the following command in the terminal.
Once the sandbox environment is running, you would also generate the configuration files for your application. However, Xcode won't be able to recognize them. For recognizing the files, you need to drag and drop the generated files to your project.
Amplify Gen 2 introduces a fully typed experience for data that no longer requires an explicit codegen step, unlike in Amplify Gen 1. You will only need this command if you are building a mobile app or have Gen 1 requirements.
186
+
187
+
Amplify Gen 2 introduces a fully typed experience for data that no longer requires an explicit codegen step, unlike in Amplify Gen 1. You will only need this command if you are building a mobile app or have Gen 1 requirements.
188
+
218
189
</Callout>
219
190
220
191
Codegen generates native code for Swift (iOS), Java (Android), and JavaScript that represents your GraphQL API's data models. It can also generate GraphQL statements (queries, mutations, and subscriptions) so that you don't have to manually code them.
Move the generated files to your project. You can do this by dragging and dropping the files to your project.
249
-
250
-

251
-
</InlineFilter>
252
199
253
200
## Delete a sandbox
254
201
255
202
You can delete a cloud sandbox environment in several ways:
256
203
257
204
1. Ctrl+C your sandbox and choose to delete resources.
258
205
1. Run `npx amplify sandbox delete` or `npx amplify sandbox delete --name`
259
-
1. Visit the Amplify console and [delete sandboxes](/[platform]/deploy-and-host/sandbox-environments/setup/#manage-sandbox-environments).
206
+
1. Visit the Amplify console and [delete sandboxes](/gen2/deploy-and-host/sandbox-environments/setup/#manage-sandbox-environments).
0 commit comments