The network setup process will configure and deploy network resources needed by other modules. In particular, it will:
- Create a nondefault VPC
- Create public subnets for publicly accessible resources such as the application load balancer, private subnets for the application service, and private subnets for the database.
- Create VPC endpoints for the AWS services needed by ECS Fargate to fetch the container image and log to AWS CloudWatch. If your application has a database, it will also create VPC endpoints for the AWS services needed by the database layer and a security group to contain those VPC endpoints.
Before setting up the network you'll need to have:
- Set up the AWS account
- Optionally adjust the configuration for the networks you want to have on your project in the project-config module. By default, there are three networks defined, one for each application environment. If you have multiple apps and want your applications in separate networks, you may want to give the networks differentiating names (e.g. "foo-dev", "foo-prod", "bar-dev", "bar-prod", instead of just "dev", "prod").
- Optionally, configure custom domains. You can also come back to setting up custom domains at a later time.
- Optionally, configure HTTPS support. You can also come back to setting up HTTPS support at a later time.
- Configure the app.
- Update
has_databasetotrueorfalsedepending on whether or not your application has a database to integrate with. This setting determines whether or not to create VPC endpoints needed by the database layer. - Update
has_external_non_aws_servicetotrueorfalsedepending on whether or not your application makes calls over the public internet. Set this totrue(a) if your application makes calls to a SaaS service, or (b) if your application needs to call services from another application in the same git repo. This setting determines whether or not to create NAT gateways, which allows the service in the private subnet to make requests to the internet. For more information, see set up network access to the public internet - If you made changes to the configuration of the networks in the optional step 2 above and or to the default application environments: Update
network_namefor your application environments. This mapping ensures that each network is configured appropriately based on the application(s) in that network (seelocal.apps_in_networkin /infra/networks/main.tf) Failure to set the network name properly means that the network layer may not receive the correct application configurations forhas_databaseandhas_external_non_aws_service.
- Update
To create the tfbackend file for the new network, run
make infra-configure-network NETWORK_NAME=<NETWORK_NAME>Now run the following commands to create the resources. Review the terraform before confirming "yes" to apply the changes.
make infra-update-network NETWORK_NAME=<NETWORK_NAME>If you make changes to your application's configuration that impact the network (such as has_database and has_external_non_aws_service), make sure to update the network before you update or deploy subsequent infrastructure layers.