DigitalOcean

v4.16.0 published on Wednesday, Sep 28, 2022 by Pulumi

ProjectResources

Assign resources to a DigitalOcean Project. This is useful if you need to assign resources managed via this provider to a DigitalOcean Project managed outside of the provider.

The following resource types can be associated with a project:

  • Database Clusters
  • Domains
  • Droplets
  • Floating IP
  • Kubernetes Cluster
  • Load Balancers
  • Spaces Bucket
  • Volume

Example Usage

The following example assigns a droplet to a Project managed outside of the provider

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var playground = DigitalOcean.GetProject.Invoke(new()
    {
        Name = "playground",
    });

    var foobar = new DigitalOcean.Droplet("foobar", new()
    {
        Size = "s-1vcpu-1gb",
        Image = "ubuntu-22-04-x64",
        Region = "nyc3",
    });

    var barfoo = new DigitalOcean.ProjectResources("barfoo", new()
    {
        Project = data.Digitalocean_project.Foo.Id,
        Resources = new[]
        {
            foobar.DropletUrn,
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := digitalocean.LookupProject(ctx, &GetProjectArgs{
			Name: pulumi.StringRef("playground"),
		}, nil)
		if err != nil {
			return err
		}
		foobar, err := digitalocean.NewDroplet(ctx, "foobar", &digitalocean.DropletArgs{
			Size:   pulumi.String("s-1vcpu-1gb"),
			Image:  pulumi.String("ubuntu-22-04-x64"),
			Region: pulumi.String("nyc3"),
		})
		if err != nil {
			return err
		}
		_, err = digitalocean.NewProjectResources(ctx, "barfoo", &digitalocean.ProjectResourcesArgs{
			Project: pulumi.Any(data.Digitalocean_project.Foo.Id),
			Resources: pulumi.StringArray{
				foobar.DropletUrn,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetProjectArgs;
import com.pulumi.digitalocean.Droplet;
import com.pulumi.digitalocean.DropletArgs;
import com.pulumi.digitalocean.ProjectResources;
import com.pulumi.digitalocean.ProjectResourcesArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var playground = DigitaloceanFunctions.getProject(GetProjectArgs.builder()
            .name("playground")
            .build());

        var foobar = new Droplet("foobar", DropletArgs.builder()        
            .size("s-1vcpu-1gb")
            .image("ubuntu-22-04-x64")
            .region("nyc3")
            .build());

        var barfoo = new ProjectResources("barfoo", ProjectResourcesArgs.builder()        
            .project(data.digitalocean_project().foo().id())
            .resources(foobar.dropletUrn())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

playground = digitalocean.get_project(name="playground")
foobar = digitalocean.Droplet("foobar",
    size="s-1vcpu-1gb",
    image="ubuntu-22-04-x64",
    region="nyc3")
barfoo = digitalocean.ProjectResources("barfoo",
    project=data["digitalocean_project"]["foo"]["id"],
    resources=[foobar.droplet_urn])
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const playground = digitalocean.getProject({
    name: "playground",
});
const foobar = new digitalocean.Droplet("foobar", {
    size: "s-1vcpu-1gb",
    image: "ubuntu-22-04-x64",
    region: "nyc3",
});
const barfoo = new digitalocean.ProjectResources("barfoo", {
    project: data.digitalocean_project.foo.id,
    resources: [foobar.dropletUrn],
});
resources:
  foobar:
    type: digitalocean:Droplet
    properties:
      size: s-1vcpu-1gb
      image: ubuntu-22-04-x64
      region: nyc3
  barfoo:
    type: digitalocean:ProjectResources
    properties:
      project: ${data.digitalocean_project.foo.id}
      resources:
        - ${foobar.dropletUrn}
variables:
  playground:
    Fn::Invoke:
      Function: digitalocean:getProject
      Arguments:
        name: playground

Create ProjectResources Resource

new ProjectResources(name: string, args: ProjectResourcesArgs, opts?: CustomResourceOptions);
@overload
def ProjectResources(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     project: Optional[str] = None,
                     resources: Optional[Sequence[str]] = None)
@overload
def ProjectResources(resource_name: str,
                     args: ProjectResourcesArgs,
                     opts: Optional[ResourceOptions] = None)
func NewProjectResources(ctx *Context, name string, args ProjectResourcesArgs, opts ...ResourceOption) (*ProjectResources, error)
public ProjectResources(string name, ProjectResourcesArgs args, CustomResourceOptions? opts = null)
public ProjectResources(String name, ProjectResourcesArgs args)
public ProjectResources(String name, ProjectResourcesArgs args, CustomResourceOptions options)
type: digitalocean:ProjectResources
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args ProjectResourcesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args ProjectResourcesArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ProjectResourcesArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ProjectResourcesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ProjectResourcesArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

ProjectResources Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The ProjectResources resource accepts the following input properties:

Project string

the ID of the project

Resources List<string>

a list of uniform resource names (URNs) for the resources associated with the project

Project string

the ID of the project

Resources []string

a list of uniform resource names (URNs) for the resources associated with the project

project String

the ID of the project

resources List<String>

a list of uniform resource names (URNs) for the resources associated with the project

project string

the ID of the project

resources string[]

a list of uniform resource names (URNs) for the resources associated with the project

project str

the ID of the project

resources Sequence[str]

a list of uniform resource names (URNs) for the resources associated with the project

project String

the ID of the project

resources List<String>

a list of uniform resource names (URNs) for the resources associated with the project

Outputs

All input properties are implicitly available as output properties. Additionally, the ProjectResources resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing ProjectResources Resource

Get an existing ProjectResources resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ProjectResourcesState, opts?: CustomResourceOptions): ProjectResources
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        project: Optional[str] = None,
        resources: Optional[Sequence[str]] = None) -> ProjectResources
func GetProjectResources(ctx *Context, name string, id IDInput, state *ProjectResourcesState, opts ...ResourceOption) (*ProjectResources, error)
public static ProjectResources Get(string name, Input<string> id, ProjectResourcesState? state, CustomResourceOptions? opts = null)
public static ProjectResources get(String name, Output<String> id, ProjectResourcesState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Project string

the ID of the project

Resources List<string>

a list of uniform resource names (URNs) for the resources associated with the project

Project string

the ID of the project

Resources []string

a list of uniform resource names (URNs) for the resources associated with the project

project String

the ID of the project

resources List<String>

a list of uniform resource names (URNs) for the resources associated with the project

project string

the ID of the project

resources string[]

a list of uniform resource names (URNs) for the resources associated with the project

project str

the ID of the project

resources Sequence[str]

a list of uniform resource names (URNs) for the resources associated with the project

project String

the ID of the project

resources List<String>

a list of uniform resource names (URNs) for the resources associated with the project

Import

Importing this resource is not supported.

Package Details

Repository
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.