1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. SpacesKey
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

digitalocean.SpacesKey

Explore with Pulumi AI

Provides a key resource for Spaces, DigitalOcean’s object storage product.

The Spaces API was designed to be interoperable with Amazon’s AWS S3 API. This allows users to interact with the service while using the tools they already know. Spaces mirrors S3’s authentication framework and requests to Spaces require a key pair similar to Amazon’s Access ID and Secret Key.

As a Spaces owner, you limit others’ access to your buckets using Spaces access keys. Access keys can provide several levels of permissions to create, destroy, read, and write to specific associated buckets. However, access keys only limit access to certain commands using the S3 API or CLI, not the control panel or other DigitalOcean resources.

Example Usage

Create a New Key

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const foobar = new digitalocean.SpacesKey("foobar", {name: "foobar"});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

foobar = digitalocean.SpacesKey("foobar", name="foobar")
Copy
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.NewSpacesKey(ctx, "foobar", &digitalocean.SpacesKeyArgs{
			Name: pulumi.String("foobar"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var foobar = new DigitalOcean.SpacesKey("foobar", new()
    {
        Name = "foobar",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.SpacesKey;
import com.pulumi.digitalocean.SpacesKeyArgs;
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) {
        var foobar = new SpacesKey("foobar", SpacesKeyArgs.builder()
            .name("foobar")
            .build());

    }
}
Copy
resources:
  foobar:
    type: digitalocean:SpacesKey
    properties:
      name: foobar
Copy

Create a New Key with Grants

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const foobar = new digitalocean.SpacesKey("foobar", {
    name: "foobar",
    grants: [{
        bucket: "my-bucket",
        permission: "read",
    }],
});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

foobar = digitalocean.SpacesKey("foobar",
    name="foobar",
    grants=[{
        "bucket": "my-bucket",
        "permission": "read",
    }])
Copy
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.NewSpacesKey(ctx, "foobar", &digitalocean.SpacesKeyArgs{
			Name: pulumi.String("foobar"),
			Grants: digitalocean.SpacesKeyGrantArray{
				&digitalocean.SpacesKeyGrantArgs{
					Bucket:     pulumi.String("my-bucket"),
					Permission: pulumi.String("read"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var foobar = new DigitalOcean.SpacesKey("foobar", new()
    {
        Name = "foobar",
        Grants = new[]
        {
            new DigitalOcean.Inputs.SpacesKeyGrantArgs
            {
                Bucket = "my-bucket",
                Permission = "read",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.SpacesKey;
import com.pulumi.digitalocean.SpacesKeyArgs;
import com.pulumi.digitalocean.inputs.SpacesKeyGrantArgs;
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) {
        var foobar = new SpacesKey("foobar", SpacesKeyArgs.builder()
            .name("foobar")
            .grants(SpacesKeyGrantArgs.builder()
                .bucket("my-bucket")
                .permission("read")
                .build())
            .build());

    }
}
Copy
resources:
  foobar:
    type: digitalocean:SpacesKey
    properties:
      name: foobar
      grants:
        - bucket: my-bucket
          permission: read
Copy

Create a New Key with full access

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const foobar = new digitalocean.SpacesKey("foobar", {
    name: "foobar",
    grants: [{
        bucket: "",
        permission: "fullaccess",
    }],
});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

foobar = digitalocean.SpacesKey("foobar",
    name="foobar",
    grants=[{
        "bucket": "",
        "permission": "fullaccess",
    }])
Copy
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.NewSpacesKey(ctx, "foobar", &digitalocean.SpacesKeyArgs{
			Name: pulumi.String("foobar"),
			Grants: digitalocean.SpacesKeyGrantArray{
				&digitalocean.SpacesKeyGrantArgs{
					Bucket:     pulumi.String(""),
					Permission: pulumi.String("fullaccess"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var foobar = new DigitalOcean.SpacesKey("foobar", new()
    {
        Name = "foobar",
        Grants = new[]
        {
            new DigitalOcean.Inputs.SpacesKeyGrantArgs
            {
                Bucket = "",
                Permission = "fullaccess",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.SpacesKey;
import com.pulumi.digitalocean.SpacesKeyArgs;
import com.pulumi.digitalocean.inputs.SpacesKeyGrantArgs;
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) {
        var foobar = new SpacesKey("foobar", SpacesKeyArgs.builder()
            .name("foobar")
            .grants(SpacesKeyGrantArgs.builder()
                .bucket("")
                .permission("fullaccess")
                .build())
            .build());

    }
}
Copy
resources:
  foobar:
    type: digitalocean:SpacesKey
    properties:
      name: foobar
      grants:
        - bucket: ""
          permission: fullaccess
Copy

Create SpacesKey Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new SpacesKey(name: string, args?: SpacesKeyArgs, opts?: CustomResourceOptions);
@overload
def SpacesKey(resource_name: str,
              args: Optional[SpacesKeyArgs] = None,
              opts: Optional[ResourceOptions] = None)

@overload
def SpacesKey(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              grants: Optional[Sequence[SpacesKeyGrantArgs]] = None,
              name: Optional[str] = None)
func NewSpacesKey(ctx *Context, name string, args *SpacesKeyArgs, opts ...ResourceOption) (*SpacesKey, error)
public SpacesKey(string name, SpacesKeyArgs? args = null, CustomResourceOptions? opts = null)
public SpacesKey(String name, SpacesKeyArgs args)
public SpacesKey(String name, SpacesKeyArgs args, CustomResourceOptions options)
type: digitalocean:SpacesKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

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

Constructor example

The following reference example uses placeholder values for all input properties.

var spacesKeyResource = new DigitalOcean.SpacesKey("spacesKeyResource", new()
{
    Grants = new[]
    {
        new DigitalOcean.Inputs.SpacesKeyGrantArgs
        {
            Bucket = "string",
            Permission = "string",
        },
    },
    Name = "string",
});
Copy
example, err := digitalocean.NewSpacesKey(ctx, "spacesKeyResource", &digitalocean.SpacesKeyArgs{
	Grants: digitalocean.SpacesKeyGrantArray{
		&digitalocean.SpacesKeyGrantArgs{
			Bucket:     pulumi.String("string"),
			Permission: pulumi.String("string"),
		},
	},
	Name: pulumi.String("string"),
})
Copy
var spacesKeyResource = new SpacesKey("spacesKeyResource", SpacesKeyArgs.builder()
    .grants(SpacesKeyGrantArgs.builder()
        .bucket("string")
        .permission("string")
        .build())
    .name("string")
    .build());
Copy
spaces_key_resource = digitalocean.SpacesKey("spacesKeyResource",
    grants=[{
        "bucket": "string",
        "permission": "string",
    }],
    name="string")
Copy
const spacesKeyResource = new digitalocean.SpacesKey("spacesKeyResource", {
    grants: [{
        bucket: "string",
        permission: "string",
    }],
    name: "string",
});
Copy
type: digitalocean:SpacesKey
properties:
    grants:
        - bucket: string
          permission: string
    name: string
Copy

SpacesKey Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The SpacesKey resource accepts the following input properties:

Grants List<Pulumi.DigitalOcean.Inputs.SpacesKeyGrant>
A grant for the key (documented below).
Name string
The name of the key
Grants []SpacesKeyGrantArgs
A grant for the key (documented below).
Name string
The name of the key
grants List<SpacesKeyGrant>
A grant for the key (documented below).
name String
The name of the key
grants SpacesKeyGrant[]
A grant for the key (documented below).
name string
The name of the key
grants Sequence[SpacesKeyGrantArgs]
A grant for the key (documented below).
name str
The name of the key
grants List<Property Map>
A grant for the key (documented below).
name String
The name of the key

Outputs

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

AccessKey string
The access key ID of the key
CreatedAt string
The creation time of the key
Id string
The provider-assigned unique ID for this managed resource.
SecretKey string
The access key secret of the key
AccessKey string
The access key ID of the key
CreatedAt string
The creation time of the key
Id string
The provider-assigned unique ID for this managed resource.
SecretKey string
The access key secret of the key
accessKey String
The access key ID of the key
createdAt String
The creation time of the key
id String
The provider-assigned unique ID for this managed resource.
secretKey String
The access key secret of the key
accessKey string
The access key ID of the key
createdAt string
The creation time of the key
id string
The provider-assigned unique ID for this managed resource.
secretKey string
The access key secret of the key
access_key str
The access key ID of the key
created_at str
The creation time of the key
id str
The provider-assigned unique ID for this managed resource.
secret_key str
The access key secret of the key
accessKey String
The access key ID of the key
createdAt String
The creation time of the key
id String
The provider-assigned unique ID for this managed resource.
secretKey String
The access key secret of the key

Look up Existing SpacesKey Resource

Get an existing SpacesKey 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?: SpacesKeyState, opts?: CustomResourceOptions): SpacesKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_key: Optional[str] = None,
        created_at: Optional[str] = None,
        grants: Optional[Sequence[SpacesKeyGrantArgs]] = None,
        name: Optional[str] = None,
        secret_key: Optional[str] = None) -> SpacesKey
func GetSpacesKey(ctx *Context, name string, id IDInput, state *SpacesKeyState, opts ...ResourceOption) (*SpacesKey, error)
public static SpacesKey Get(string name, Input<string> id, SpacesKeyState? state, CustomResourceOptions? opts = null)
public static SpacesKey get(String name, Output<String> id, SpacesKeyState state, CustomResourceOptions options)
resources:  _:    type: digitalocean:SpacesKey    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
AccessKey string
The access key ID of the key
CreatedAt string
The creation time of the key
Grants List<Pulumi.DigitalOcean.Inputs.SpacesKeyGrant>
A grant for the key (documented below).
Name string
The name of the key
SecretKey string
The access key secret of the key
AccessKey string
The access key ID of the key
CreatedAt string
The creation time of the key
Grants []SpacesKeyGrantArgs
A grant for the key (documented below).
Name string
The name of the key
SecretKey string
The access key secret of the key
accessKey String
The access key ID of the key
createdAt String
The creation time of the key
grants List<SpacesKeyGrant>
A grant for the key (documented below).
name String
The name of the key
secretKey String
The access key secret of the key
accessKey string
The access key ID of the key
createdAt string
The creation time of the key
grants SpacesKeyGrant[]
A grant for the key (documented below).
name string
The name of the key
secretKey string
The access key secret of the key
access_key str
The access key ID of the key
created_at str
The creation time of the key
grants Sequence[SpacesKeyGrantArgs]
A grant for the key (documented below).
name str
The name of the key
secret_key str
The access key secret of the key
accessKey String
The access key ID of the key
createdAt String
The creation time of the key
grants List<Property Map>
A grant for the key (documented below).
name String
The name of the key
secretKey String
The access key secret of the key

Supporting Types

SpacesKeyGrant
, SpacesKeyGrantArgs

Bucket This property is required. string
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
Permission This property is required. string
Permission associated with this grant. Values can be read, readwrite, fullaccess.
Bucket This property is required. string
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
Permission This property is required. string
Permission associated with this grant. Values can be read, readwrite, fullaccess.
bucket This property is required. String
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
permission This property is required. String
Permission associated with this grant. Values can be read, readwrite, fullaccess.
bucket This property is required. string
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
permission This property is required. string
Permission associated with this grant. Values can be read, readwrite, fullaccess.
bucket This property is required. str
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
permission This property is required. str
Permission associated with this grant. Values can be read, readwrite, fullaccess.
bucket This property is required. String
Name of the bucket associated with this grant. In case of a fullaccess permission, this value should be an empty string.
permission This property is required. String
Permission associated with this grant. Values can be read, readwrite, fullaccess.

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes
This Pulumi package is based on the digitalocean Terraform Provider.