We are using Terraform to manage all of our DigitalOcean infrastructure, with different environments (prod, staging, dev), that we separate by projects. Terraform is designed with multiple child modules (application, ci, vpc..). As everything is working fine, I'm still looking for the answer on an architectural question.
What's the most ideal scenario to attach resources (droplets, spaces, load balancers, domains..) to a DigitalOcean project in Terraform? First of all, the most ideal way for us would be a separate API key per project, but unfortunately this is not possible with DigitalOcean. We are working with a root module and multiple child modules (application, ci, vpc...) to provision our infrastructure.
I'm considering multiple possibilities:
The first possibility is to make the digitalocean_project resource in the root module . Each child module has an output (urn) of all the resources that needs to be attached to a project. In the root module , each resource is attached to the specified project with the digitalocean_project_resources resource.
By this way the child modules "are not aware' of the fact that the resources are belonging to a project.
Second possibility is also to create digitalocean_project resource in the root module. Each child module has an input (id) of the create project in the root module. In the child modules (application, ci, vpc...), each resource is attached to a project with digitalocean_project_resources and uses the id of the project as input.
By this way the child modules "are aware" of the fact that the resources are belonging to a project.
A third and last possibility is to create a module: "project", which will create the project and attach all of the resources (urn as a input of the module), to the created project.
Fourth and last possibility that I have in mind is to create a separate DigitalOcean account. This is only a last resort, as this will make things more complex.
We are using Terraform to manage all of our DigitalOcean infrastructure, with different environments (prod, staging, dev), that we separate by projects. Terraform is designed with multiple child modules (application, ci, vpc..). As everything is working fine, I'm still looking for the answer on an architectural question.
What's the most ideal scenario to attach resources (droplets, spaces, load balancers, domains..) to a DigitalOcean project in Terraform? First of all, the most ideal way for us would be a separate API key per project, but unfortunately this is not possible with DigitalOcean. We are working with a root module and multiple child modules (application, ci, vpc...) to provision our infrastructure.
I'm considering multiple possibilities:
The first possibility is to make the
digitalocean_project
resource in the root module . Each child module has an output (urn) of all the resources that needs to be attached to a project. In the root module , each resource is attached to the specified project with thedigitalocean_project_resources
resource.Second possibility is also to create
digitalocean_project
resource in the root module. Each child module has an input (id) of the create project in the root module. In the child modules (application, ci, vpc...), each resource is attached to a project withdigitalocean_project_resources
and uses the id of the project as input.A third and last possibility is to create a module: "project", which will create the project and attach all of the resources (urn as a input of the module), to the created project.
Fourth and last possibility that I have in mind is to create a separate DigitalOcean account. This is only a last resort, as this will make things more complex.
Terraform Version
Affected Resource(s)
Please list the resources as a list, for example:
Expected Behavior
Easier way to attach resources (droplets, spaces, load balancers, domains) to a project (ex. production).
Actual Behavior
Complex way to attach resources to a project, one API key with all rights on the DigitalOcean account.