1. Packages
  2. Spotinst Provider
  3. API Docs
  4. organization
  5. Policy
Spotinst v3.116.0 published on Friday, Mar 28, 2025 by Pulumi

spotinst.organization.Policy

Explore with Pulumi AI

Provides a Spotinst access policy.

Example Usage

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

const terraformPolicy = new spotinst.organization.Policy("terraform_policy", {
    name: "test-policy",
    description: "policy by terraform",
    policyContents: [{
        statements: [
            {
                actions: ["ocean:deleteCluster"],
                effect: "DENY",
                resources: [
                    "o-abcd1234",
                    "o-defg6789",
                ],
            },
            {
                actions: ["ocean:createCluster"],
                effect: "DENY",
                resources: [
                    "o-fhau4752",
                    "o-761owf4r3",
                ],
            },
        ],
    }],
});
Copy
import pulumi
import pulumi_spotinst as spotinst

terraform_policy = spotinst.organization.Policy("terraform_policy",
    name="test-policy",
    description="policy by terraform",
    policy_contents=[{
        "statements": [
            {
                "actions": ["ocean:deleteCluster"],
                "effect": "DENY",
                "resources": [
                    "o-abcd1234",
                    "o-defg6789",
                ],
            },
            {
                "actions": ["ocean:createCluster"],
                "effect": "DENY",
                "resources": [
                    "o-fhau4752",
                    "o-761owf4r3",
                ],
            },
        ],
    }])
Copy
package main

import (
	"github.com/pulumi/pulumi-spotinst/sdk/v3/go/spotinst/organization"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := organization.NewPolicy(ctx, "terraform_policy", &organization.PolicyArgs{
			Name:        pulumi.String("test-policy"),
			Description: pulumi.String("policy by terraform"),
			PolicyContents: organization.PolicyPolicyContentArray{
				&organization.PolicyPolicyContentArgs{
					Statements: organization.PolicyPolicyContentStatementArray{
						&organization.PolicyPolicyContentStatementArgs{
							Actions: pulumi.StringArray{
								pulumi.String("ocean:deleteCluster"),
							},
							Effect: pulumi.String("DENY"),
							Resources: pulumi.StringArray{
								pulumi.String("o-abcd1234"),
								pulumi.String("o-defg6789"),
							},
						},
						&organization.PolicyPolicyContentStatementArgs{
							Actions: pulumi.StringArray{
								pulumi.String("ocean:createCluster"),
							},
							Effect: pulumi.String("DENY"),
							Resources: pulumi.StringArray{
								pulumi.String("o-fhau4752"),
								pulumi.String("o-761owf4r3"),
							},
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using SpotInst = Pulumi.SpotInst;

return await Deployment.RunAsync(() => 
{
    var terraformPolicy = new SpotInst.Organization.Policy("terraform_policy", new()
    {
        Name = "test-policy",
        Description = "policy by terraform",
        PolicyContents = new[]
        {
            new SpotInst.Organization.Inputs.PolicyPolicyContentArgs
            {
                Statements = new[]
                {
                    new SpotInst.Organization.Inputs.PolicyPolicyContentStatementArgs
                    {
                        Actions = new[]
                        {
                            "ocean:deleteCluster",
                        },
                        Effect = "DENY",
                        Resources = new[]
                        {
                            "o-abcd1234",
                            "o-defg6789",
                        },
                    },
                    new SpotInst.Organization.Inputs.PolicyPolicyContentStatementArgs
                    {
                        Actions = new[]
                        {
                            "ocean:createCluster",
                        },
                        Effect = "DENY",
                        Resources = new[]
                        {
                            "o-fhau4752",
                            "o-761owf4r3",
                        },
                    },
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.spotinst.organization.Policy;
import com.pulumi.spotinst.organization.PolicyArgs;
import com.pulumi.spotinst.organization.inputs.PolicyPolicyContentArgs;
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 terraformPolicy = new Policy("terraformPolicy", PolicyArgs.builder()
            .name("test-policy")
            .description("policy by terraform")
            .policyContents(PolicyPolicyContentArgs.builder()
                .statements(                
                    PolicyPolicyContentStatementArgs.builder()
                        .actions("ocean:deleteCluster")
                        .effect("DENY")
                        .resources(                        
                            "o-abcd1234",
                            "o-defg6789")
                        .build(),
                    PolicyPolicyContentStatementArgs.builder()
                        .actions("ocean:createCluster")
                        .effect("DENY")
                        .resources(                        
                            "o-fhau4752",
                            "o-761owf4r3")
                        .build())
                .build())
            .build());

    }
}
Copy
resources:
  terraformPolicy:
    type: spotinst:organization:Policy
    name: terraform_policy
    properties:
      name: test-policy
      description: policy by terraform
      policyContents:
        - statements:
            - actions:
                - ocean:deleteCluster
              effect: DENY
              resources:
                - o-abcd1234
                - o-defg6789
            - actions:
                - ocean:createCluster
              effect: DENY
              resources:
                - o-fhau4752
                - o-761owf4r3
Copy

Create Policy Resource

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

Constructor syntax

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

@overload
def Policy(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           policy_contents: Optional[Sequence[PolicyPolicyContentArgs]] = None,
           description: Optional[str] = None,
           name: Optional[str] = None)
func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
public Policy(String name, PolicyArgs args)
public Policy(String name, PolicyArgs args, CustomResourceOptions options)
type: spotinst:organization:Policy
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 This property is required. PolicyArgs
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 This property is required. PolicyArgs
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 This property is required. PolicyArgs
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 This property is required. PolicyArgs
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. PolicyArgs
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 policyResource = new SpotInst.Organization.Policy("policyResource", new()
{
    PolicyContents = new[]
    {
        new SpotInst.Organization.Inputs.PolicyPolicyContentArgs
        {
            Statements = new[]
            {
                new SpotInst.Organization.Inputs.PolicyPolicyContentStatementArgs
                {
                    Actions = new[]
                    {
                        "string",
                    },
                    Effect = "string",
                    Resources = new[]
                    {
                        "string",
                    },
                },
            },
        },
    },
    Description = "string",
    Name = "string",
});
Copy
example, err := organization.NewPolicy(ctx, "policyResource", &organization.PolicyArgs{
	PolicyContents: organization.PolicyPolicyContentArray{
		&organization.PolicyPolicyContentArgs{
			Statements: organization.PolicyPolicyContentStatementArray{
				&organization.PolicyPolicyContentStatementArgs{
					Actions: pulumi.StringArray{
						pulumi.String("string"),
					},
					Effect: pulumi.String("string"),
					Resources: pulumi.StringArray{
						pulumi.String("string"),
					},
				},
			},
		},
	},
	Description: pulumi.String("string"),
	Name:        pulumi.String("string"),
})
Copy
var policyResource = new Policy("policyResource", PolicyArgs.builder()
    .policyContents(PolicyPolicyContentArgs.builder()
        .statements(PolicyPolicyContentStatementArgs.builder()
            .actions("string")
            .effect("string")
            .resources("string")
            .build())
        .build())
    .description("string")
    .name("string")
    .build());
Copy
policy_resource = spotinst.organization.Policy("policyResource",
    policy_contents=[{
        "statements": [{
            "actions": ["string"],
            "effect": "string",
            "resources": ["string"],
        }],
    }],
    description="string",
    name="string")
Copy
const policyResource = new spotinst.organization.Policy("policyResource", {
    policyContents: [{
        statements: [{
            actions: ["string"],
            effect: "string",
            resources: ["string"],
        }],
    }],
    description: "string",
    name: "string",
});
Copy
type: spotinst:organization:Policy
properties:
    description: string
    name: string
    policyContents:
        - statements:
            - actions:
                - string
              effect: string
              resources:
                - string
Copy

Policy 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 Policy resource accepts the following input properties:

PolicyContents This property is required. List<Pulumi.SpotInst.Organization.Inputs.PolicyPolicyContent>
Set permissions objects list.
Description string
Short description of policy.
Name string
Name of the Policy.
PolicyContents This property is required. []PolicyPolicyContentArgs
Set permissions objects list.
Description string
Short description of policy.
Name string
Name of the Policy.
policyContents This property is required. List<PolicyPolicyContent>
Set permissions objects list.
description String
Short description of policy.
name String
Name of the Policy.
policyContents This property is required. PolicyPolicyContent[]
Set permissions objects list.
description string
Short description of policy.
name string
Name of the Policy.
policy_contents This property is required. Sequence[PolicyPolicyContentArgs]
Set permissions objects list.
description str
Short description of policy.
name str
Name of the Policy.
policyContents This property is required. List<Property Map>
Set permissions objects list.
description String
Short description of policy.
name String
Name of the Policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the Policy 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 Policy Resource

Get an existing Policy 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?: PolicyState, opts?: CustomResourceOptions): Policy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        policy_contents: Optional[Sequence[PolicyPolicyContentArgs]] = None) -> Policy
func GetPolicy(ctx *Context, name string, id IDInput, state *PolicyState, opts ...ResourceOption) (*Policy, error)
public static Policy Get(string name, Input<string> id, PolicyState? state, CustomResourceOptions? opts = null)
public static Policy get(String name, Output<String> id, PolicyState state, CustomResourceOptions options)
resources:  _:    type: spotinst:organization:Policy    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:
Description string
Short description of policy.
Name string
Name of the Policy.
PolicyContents List<Pulumi.SpotInst.Organization.Inputs.PolicyPolicyContent>
Set permissions objects list.
Description string
Short description of policy.
Name string
Name of the Policy.
PolicyContents []PolicyPolicyContentArgs
Set permissions objects list.
description String
Short description of policy.
name String
Name of the Policy.
policyContents List<PolicyPolicyContent>
Set permissions objects list.
description string
Short description of policy.
name string
Name of the Policy.
policyContents PolicyPolicyContent[]
Set permissions objects list.
description str
Short description of policy.
name str
Name of the Policy.
policy_contents Sequence[PolicyPolicyContentArgs]
Set permissions objects list.
description String
Short description of policy.
name String
Name of the Policy.
policyContents List<Property Map>
Set permissions objects list.

Supporting Types

PolicyPolicyContent
, PolicyPolicyContentArgs

Statements This property is required. List<Pulumi.SpotInst.Organization.Inputs.PolicyPolicyContentStatement>
List of permissions statements.
Statements This property is required. []PolicyPolicyContentStatement
List of permissions statements.
statements This property is required. List<PolicyPolicyContentStatement>
List of permissions statements.
statements This property is required. PolicyPolicyContentStatement[]
List of permissions statements.
statements This property is required. Sequence[PolicyPolicyContentStatement]
List of permissions statements.
statements This property is required. List<Property Map>
List of permissions statements.

PolicyPolicyContentStatement
, PolicyPolicyContentStatementArgs

Actions This property is required. List<string>
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
Effect This property is required. string
Valid values "ALLOW", "DENY".
Resources This property is required. List<string>
Set a list of resources IDs. In order to include all resources in this statement - use "*".
Actions This property is required. []string
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
Effect This property is required. string
Valid values "ALLOW", "DENY".
Resources This property is required. []string
Set a list of resources IDs. In order to include all resources in this statement - use "*".
actions This property is required. List<String>
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
effect This property is required. String
Valid values "ALLOW", "DENY".
resources This property is required. List<String>
Set a list of resources IDs. In order to include all resources in this statement - use "*".
actions This property is required. string[]
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
effect This property is required. string
Valid values "ALLOW", "DENY".
resources This property is required. string[]
Set a list of resources IDs. In order to include all resources in this statement - use "*".
actions This property is required. Sequence[str]
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
effect This property is required. str
Valid values "ALLOW", "DENY".
resources This property is required. Sequence[str]
Set a list of resources IDs. In order to include all resources in this statement - use "*".
actions This property is required. List<String>
Set a list of required actions for this permissions statement. Full list of actions can be found in https://docs.spot.io/account-user-management/user-management/access-policies-actions/.
effect This property is required. String
Valid values "ALLOW", "DENY".
resources This property is required. List<String>
Set a list of resources IDs. In order to include all resources in this statement - use "*".

Package Details

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