- AWS EC2
The provided configuration automates the creation of the EC2 instance, sets up the necessary security group rules, and uses a startup script to install and configure the Infisical Relay service.
Prerequisites
Before you start, make sure you have the following:- An AWS account with permissions to create EC2 instances, Security Groups, and Elastic IPs.
- An existing VPC and Subnet ID in your desired AWS region.
- The AMI ID for your chosen OS (this guide uses an Ubuntu 22.04 LTS AMI).
- Credentials for the Infisical Relay to authenticate with your Infisical instance. This guide uses a Machine Identity token, but other methods are available. You can find a full list of authentication options here.
Terraform Configuration
Here is the complete Terraform configuration to deploy the Infisical Relay.The provided security group rules are open to the internet (
0.0.0.0/0) for simplicity. In a production environment, you should restrict the cidr_blocks to known IP addresses for enhanced security, especially for the SSH port (22).How to Deploy
- Save the configuration: Save the code above to a file named main.tf.
- Customize values: Update the placeholder values in main.tfto match your AWS environment and Infisical credentials. You’ll need to replace:- regionin the- providerblock.
- vpc_idin the- aws_security_groupresource.
- amiand- subnet_idin the- infisical_relay_instancemodule.
- The INFISICAL_TOKENenvironment variable in theuser_datascript (e.g.,export INFISICAL_TOKEN="your-machine-identity-token").
- The --domainin theuser_datascript if you are self-hosting Infisical.
 
- Apply the configuration: Run the following Terraform commands in your terminal: