This approach enables you to fetch secrets from Infisical during Amplify build time.
Machine Identity (Recommended)
Service Token (Deprecated)
1
Create a machine identity
Create a machine identity and connect it to your Infisical project. You can read more about how to use machine identities here. The machine identity will allow you to authenticate and fetch secrets from Infisical.
2
Set the machine identity client ID and client secret as Amplify environment variables
In the Amplify console, choose App Settings, and then select Environment variables.
In the Environment variables section, select Manage variables.
Under the first Variable enter INFISICAL_MACHINE_IDENTITY_CLIENT_ID, and for the value, enter the client ID of the machine identity you created in the previous step.
Under the second Variable enter INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET, and for the value, enter the client secret of the machine identity you created in the previous step.
Click save.
3
Install Infisical CLI to the Amplify build step
In the prebuild phase, add the command in AWS Amplify to install the Infisical CLI.
Go to your project settings in the Infisical dashboard to generate a service token. This service token will allow you to authenticate and fetch secrets from Infisical. Once you have created a service token with the required permissions, you’ll need to provide the token to the CLI installed in your Docker container.
2
Set the service token as an Amplify environment variable
In the Amplify console, choose App Settings, and then select Environment variables.
In the Environment variables section, select Manage variables.
Under Variable, enter the key INFISICAL_TOKEN. For the value, enter the generated service token from the previous step.
Click save.
3
Install Infisical CLI to the Amplify build step
In the prebuild phase, add the command in AWS Amplify to install the Infisical CLI.
Another approach to use secrets from Infisical in AWS Amplify is to utilize AWS Parameter Store.
At high level, you begin by using Infisical’s AWS SSM Parameter Store integration to sync secrets from Infisical to AWS SSM Parameter Store. You then instruct AWS Amplify to consume those secrets from AWS SSM Parameter Store as environment secrets.
1
Follow the AWS SSM Parameter Store Integration guide
The App ID will be the last part of the App ARN field after the slash.
3
Set AWS SSM Parameter Store path
You need to set the path in the format /amplify/[amplify_app_id]/[your-amplify-environment-name] as the path option in AWS SSM Parameter Infisical Integration.
Accessing an environment secret during a build is similar to accessing
environment variables, except that environment secrets are stored in
process.env.secrets as a JSON string.