To use the provider:
- Run
go build -o terraform-provider-aptible
. - Add a config file in the root directory named
main.tf
. - Run
terraform init
. - Run
terraform plan
. - Run
terraform apply
. Warning: This step will cause real resources to be created!
This provider has 4 resources: apps, databases, endpoints, and replicas.
- Deployment
- Currently, only direct docker image deployment is supported.
- For more information on direct docker image deployment, refer to the Aptible Deploy documentation.
- Configuration
- Configuration is done via setting environment variables.
- For more information on configuration variables in Aptible Deploy, refer to the Aptible Deploy documentation.
- Connecting to a database can be done using the variable
DATABASE_URL
and setting it to the database's connection URL.
This provider has 1 data source: environments.
- The environments data source gets the environment ID corresponding to a given handle.
You can find an example configuration file in examples/main.tf
.
Below are the attributes defined in the app config with the accepted values.
-
env_id (environment ID): use
data.aptible_environment.<environment_name>.env_id
. For example, if your environment is calledtest
, then the config should contain:env_id = data.aptible_environment.test.env_id
-
handle (app handle): the handle for your app. For example, if your app is called
test
, then the config should contain:handle = "test"
-
config: the configuration for your app. This can include:
APTIBLE_DOCKER_IMAGE
which is the docker image you want to use to deploy.DATABASE_URL
which is the connection URL for a database.- More examples
For example, if you wanted to deploy using the
nginx
image, then the config should contain:config = {"APTIBLE_DOCKER_IMAGE" = "nginx"}
The app_id
and git_repo
attributes will be generated upon running
terraform apply
.
Below are the attributes defined in the database config with the accepted values.
- env_id: the ID for your environment.
- handle: the handle for your database.
- db_type: the type of your database.
- container_size: the container size for your database.
- disk_size: the disk size for your database.
The db_id
and default_connection_url
attributes will be generated upon
running terraform apply
.
Below are the attributes defined in the endpoint config with the accepted values.
Below are the attributes defined in the replica config with the accepted values.
Below are the attributes defined in the environment config with the accepted values.
- handle: the handle for your environment.
For example, if your environment is called
test
, then the config should contain:handle = "test"
This provider has acceptance tests to test basic functionality for each resource, as well as tests to ensure that invalid inputs return errors.
To run the acceptance tests:
- Set the
APTIBLE_ENVIRONMENT_ID
to the test environment ID to run acceptance tests against. This will create real AWS resources. - Make sure your
APTIBLE_AUTH_ROOT_URL
,APTIBLE_API_ROOT_URL
, andAPTIBLE_ACCESS_TOKEN
environment variables are set. - Run
make testacc
.
With the default parallelization, the test take about 15 minutes to run.