project_resources

Generated on 15 Jan 2026 from digitalocean.cloud version v1.2.1

Synopsis

Assign resources to a DigitalOcean project. Resources can be assigned using their URN (Uniform Resource Name) in the format do:resource_type:resource_id, for example do:droplet:13457723. View the API documentation at https://docs.digitalocean.com/reference/api/api-reference/#operation/projects_assign_resources.

Requirements

  • pydo >= 0.1.3
  • azure-core >= 1.26.1

Parameters

Parameter Choices / Default Description
client_override_options
dict
Client override options (developer use). For example, can be used to override the DigitalOcean API endpoint for an internal test suite. If provided, these options will knock out existing options.
module_override_options
dict
Module override options (developer use). Can be used to override module options to support experimental or future options. If provided, these options will knock out existing options.
project_id
str
A unique identifier for the project. Either project_id or project_name must be specified. If both are specified, project_id takes precedence.
project_name
str
The name of the project. Either project_id or project_name must be specified. If both are specified, project_id takes precedence.
resources
list / elements=str
A list of resource URNs to assign to the project. Each URN should be in the format do:resource_type:resource_id, for example do:droplet:13457723, do:volume:6fc4c277-ea5c-448a-93cd-dd496cfef71f, do:floatingip:192.0.2.1, do:domain:example.com, do:loadbalancer:4de7ac8b-495b-4884-9a69-1050c6793cd6. Resource types supported include droplets, volumes, floating IPs, domains, and load balancers. Required when state=present.
state
str
Choices:
  • present (default)
  • absent
State of the resource, present to create, absent to destroy.
timeout
int
Default: 300 Polling timeout in seconds.
token
str
DigitalOcean API token. There are several environment variables which can be used to provide this value. DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_TOKEN, DO_API_TOKEN, DO_API_KEY, DO_OAUTH_TOKEN and OAUTH_TOKEN

Examples

- name: Assign resources to a project by project ID
  digitalocean.cloud.project_resources:
    token: "{{ token }}"
    state: present
    project_id: "4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679"
    resources:
      - "do:droplet:13457723"
      - "do:volume:6fc4c277-ea5c-448a-93cd-dd496cfef71f"
      - "do:floatingip:192.0.2.1"

- name: Assign resources to a project by project name
  digitalocean.cloud.project_resources:
    token: "{{ token }}"
    state: present
    project_name: "my-web-api"
    resources:
      - "do:droplet:13457723"
      - "do:domain:example.com"

- name: Assign a Droplet to the default project
  digitalocean.cloud.project_resources:
    token: "{{ token }}"
    state: present
    project_name: "default"
    resources:
      - "do:droplet:13457723"

Return Values

KeyReturnedDescription
error
dict
failure DigitalOcean API error.
Sample:
{
  "Message": "Informational error message.",
  "Reason": "Unauthorized",
  "Status Code": 401
}
msg
str
always Project resources result information.
Sample:
[
  "Assigned 3 resource(s) to project my-web-api (4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679)",
  "3 resource(s) would be assigned to project my-web-api (4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679)"
]
project
dict
always Project information.
Sample:
{
  "created_at": "2018-09-27T20:10:35Z",
  "description": "My website API",
  "environment": "Production",
  "id": "4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679",
  "is_default": false,
  "name": "my-web-api",
  "owner_id": 258992,
  "owner_uuid": "99525febec065ca37b2ffe4f852fd2b2581895e7",
  "purpose": "Service or API",
  "updated_at": "2018-09-27T20:10:35Z"
}
resources
list
always Resources assigned to the project.
Sample:
[
  {
    "assigned_at": "2018-09-28T19:26:37Z",
    "links": {
      "self": "https://api.digitalocean.com/v2/droplets/13457723"
    },
    "status": "ok",
    "urn": "do:droplet:13457723"
  },
  {
    "assigned_at": "2019-03-31T16:24:14Z",
    "links": {
      "self": "https://api.digitalocean.com/v2/domains/example.com"
    },
    "status": "ok",
    "urn": "do:domain:example.com"
  }
]

We can't find any results for your search.

Try using different keywords or simplifying your search terms.