1. Packages
  2. OVH
  3. API Docs
  4. CloudProject
  5. S3Policy
OVHCloud v0.45.0 published on Tuesday, Jun 4, 2024 by OVHcloud

ovh.CloudProject.S3Policy

Explore with Pulumi AI

ovh logo
OVHCloud v0.45.0 published on Tuesday, Jun 4, 2024 by OVHcloud

    Set the S3 Policy of a public cloud project user.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ovh from "@ovhcloud/pulumi-ovh";
    
    const user = new ovh.cloudproject.User("user", {
        serviceName: "XXX",
        description: "my user",
        roleNames: ["objectstore_operator"],
    });
    const myS3Credentials = new ovh.cloudproject.S3Credential("myS3Credentials", {
        serviceName: user.serviceName,
        userId: user.id,
    });
    const policy = new ovh.cloudproject.S3Policy("policy", {
        serviceName: user.serviceName,
        userId: user.id,
        policy: JSON.stringify({
            Statement: [{
                Sid: "RWContainer",
                Effect: "Allow",
                Action: [
                    "s3:GetObject",
                    "s3:PutObject",
                    "s3:DeleteObject",
                    "s3:ListBucket",
                    "s3:ListMultipartUploadParts",
                    "s3:ListBucketMultipartUploads",
                    "s3:AbortMultipartUpload",
                    "s3:GetBucketLocation",
                ],
                Resource: [
                    "arn:aws:s3:::hp-bucket",
                    "arn:aws:s3:::hp-bucket/*",
                ],
            }],
        }),
    });
    
    import pulumi
    import json
    import pulumi_ovh as ovh
    
    user = ovh.cloud_project.User("user",
        service_name="XXX",
        description="my user",
        role_names=["objectstore_operator"])
    my_s3_credentials = ovh.cloud_project.S3Credential("myS3Credentials",
        service_name=user.service_name,
        user_id=user.id)
    policy = ovh.cloud_project.S3Policy("policy",
        service_name=user.service_name,
        user_id=user.id,
        policy=json.dumps({
            "Statement": [{
                "Sid": "RWContainer",
                "Effect": "Allow",
                "Action": [
                    "s3:GetObject",
                    "s3:PutObject",
                    "s3:DeleteObject",
                    "s3:ListBucket",
                    "s3:ListMultipartUploadParts",
                    "s3:ListBucketMultipartUploads",
                    "s3:AbortMultipartUpload",
                    "s3:GetBucketLocation",
                ],
                "Resource": [
                    "arn:aws:s3:::hp-bucket",
                    "arn:aws:s3:::hp-bucket/*",
                ],
            }],
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/ovh/pulumi-ovh/sdk/go/ovh/CloudProject"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		user, err := CloudProject.NewUser(ctx, "user", &CloudProject.UserArgs{
    			ServiceName: pulumi.String("XXX"),
    			Description: pulumi.String("my user"),
    			RoleNames: pulumi.StringArray{
    				pulumi.String("objectstore_operator"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = CloudProject.NewS3Credential(ctx, "myS3Credentials", &CloudProject.S3CredentialArgs{
    			ServiceName: user.ServiceName,
    			UserId:      user.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Statement": []map[string]interface{}{
    				map[string]interface{}{
    					"Sid":    "RWContainer",
    					"Effect": "Allow",
    					"Action": []string{
    						"s3:GetObject",
    						"s3:PutObject",
    						"s3:DeleteObject",
    						"s3:ListBucket",
    						"s3:ListMultipartUploadParts",
    						"s3:ListBucketMultipartUploads",
    						"s3:AbortMultipartUpload",
    						"s3:GetBucketLocation",
    					},
    					"Resource": []string{
    						"arn:aws:s3:::hp-bucket",
    						"arn:aws:s3:::hp-bucket/*",
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = CloudProject.NewS3Policy(ctx, "policy", &CloudProject.S3PolicyArgs{
    			ServiceName: user.ServiceName,
    			UserId:      user.ID(),
    			Policy:      pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Ovh = Pulumi.Ovh;
    
    return await Deployment.RunAsync(() => 
    {
        var user = new Ovh.CloudProject.User("user", new()
        {
            ServiceName = "XXX",
            Description = "my user",
            RoleNames = new[]
            {
                "objectstore_operator",
            },
        });
    
        var myS3Credentials = new Ovh.CloudProject.S3Credential("myS3Credentials", new()
        {
            ServiceName = user.ServiceName,
            UserId = user.Id,
        });
    
        var policy = new Ovh.CloudProject.S3Policy("policy", new()
        {
            ServiceName = user.ServiceName,
            UserId = user.Id,
            Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Sid"] = "RWContainer",
                        ["Effect"] = "Allow",
                        ["Action"] = new[]
                        {
                            "s3:GetObject",
                            "s3:PutObject",
                            "s3:DeleteObject",
                            "s3:ListBucket",
                            "s3:ListMultipartUploadParts",
                            "s3:ListBucketMultipartUploads",
                            "s3:AbortMultipartUpload",
                            "s3:GetBucketLocation",
                        },
                        ["Resource"] = new[]
                        {
                            "arn:aws:s3:::hp-bucket",
                            "arn:aws:s3:::hp-bucket/*",
                        },
                    },
                },
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ovh.CloudProject.User;
    import com.pulumi.ovh.CloudProject.UserArgs;
    import com.pulumi.ovh.CloudProject.S3Credential;
    import com.pulumi.ovh.CloudProject.S3CredentialArgs;
    import com.pulumi.ovh.CloudProject.S3Policy;
    import com.pulumi.ovh.CloudProject.S3PolicyArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 user = new User("user", UserArgs.builder()
                .serviceName("XXX")
                .description("my user")
                .roleNames("objectstore_operator")
                .build());
    
            var myS3Credentials = new S3Credential("myS3Credentials", S3CredentialArgs.builder()
                .serviceName(user.serviceName())
                .userId(user.id())
                .build());
    
            var policy = new S3Policy("policy", S3PolicyArgs.builder()
                .serviceName(user.serviceName())
                .userId(user.id())
                .policy(serializeJson(
                    jsonObject(
                        jsonProperty("Statement", jsonArray(jsonObject(
                            jsonProperty("Sid", "RWContainer"),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Action", jsonArray(
                                "s3:GetObject", 
                                "s3:PutObject", 
                                "s3:DeleteObject", 
                                "s3:ListBucket", 
                                "s3:ListMultipartUploadParts", 
                                "s3:ListBucketMultipartUploads", 
                                "s3:AbortMultipartUpload", 
                                "s3:GetBucketLocation"
                            )),
                            jsonProperty("Resource", jsonArray(
                                "arn:aws:s3:::hp-bucket", 
                                "arn:aws:s3:::hp-bucket/*"
                            ))
                        )))
                    )))
                .build());
    
        }
    }
    
    resources:
      user:
        type: ovh:CloudProject:User
        properties:
          serviceName: XXX
          description: my user
          roleNames:
            - objectstore_operator
      myS3Credentials:
        type: ovh:CloudProject:S3Credential
        properties:
          serviceName: ${user.serviceName}
          userId: ${user.id}
      policy:
        type: ovh:CloudProject:S3Policy
        properties:
          serviceName: ${user.serviceName}
          userId: ${user.id}
          policy:
            fn::toJSON:
              Statement:
                - Sid: RWContainer
                  Effect: Allow
                  Action:
                    - s3:GetObject
                    - s3:PutObject
                    - s3:DeleteObject
                    - s3:ListBucket
                    - s3:ListMultipartUploadParts
                    - s3:ListBucketMultipartUploads
                    - s3:AbortMultipartUpload
                    - s3:GetBucketLocation
                  Resource:
                    - arn:aws:s3:::hp-bucket
                    - arn:aws:s3:::hp-bucket/*
    

    Create S3Policy Resource

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

    Constructor syntax

    new S3Policy(name: string, args: S3PolicyArgs, opts?: CustomResourceOptions);
    @overload
    def S3Policy(resource_name: str,
                 args: S3PolicyArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def S3Policy(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 policy: Optional[str] = None,
                 service_name: Optional[str] = None,
                 user_id: Optional[str] = None)
    func NewS3Policy(ctx *Context, name string, args S3PolicyArgs, opts ...ResourceOption) (*S3Policy, error)
    public S3Policy(string name, S3PolicyArgs args, CustomResourceOptions? opts = null)
    public S3Policy(String name, S3PolicyArgs args)
    public S3Policy(String name, S3PolicyArgs args, CustomResourceOptions options)
    
    type: ovh:CloudProject:S3Policy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args S3PolicyArgs
    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 S3PolicyArgs
    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 S3PolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args S3PolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args S3PolicyArgs
    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 s3policyResource = new Ovh.CloudProject.S3Policy("s3policyResource", new()
    {
        Policy = "string",
        ServiceName = "string",
        UserId = "string",
    });
    
    example, err := CloudProject.NewS3Policy(ctx, "s3policyResource", &CloudProject.S3PolicyArgs{
    	Policy:      pulumi.String("string"),
    	ServiceName: pulumi.String("string"),
    	UserId:      pulumi.String("string"),
    })
    
    var s3policyResource = new S3Policy("s3policyResource", S3PolicyArgs.builder()
        .policy("string")
        .serviceName("string")
        .userId("string")
        .build());
    
    s3policy_resource = ovh.cloud_project.S3Policy("s3policyResource",
        policy="string",
        service_name="string",
        user_id="string")
    
    const s3policyResource = new ovh.cloudproject.S3Policy("s3policyResource", {
        policy: "string",
        serviceName: "string",
        userId: "string",
    });
    
    type: ovh:CloudProject:S3Policy
    properties:
        policy: string
        serviceName: string
        userId: string
    

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

    Policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    ServiceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    UserId string
    The ID of a public cloud project's user.
    Policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    ServiceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    UserId string
    The ID of a public cloud project's user.
    policy String
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName String
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId String
    The ID of a public cloud project's user.
    policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId string
    The ID of a public cloud project's user.
    policy str
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    service_name str
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    user_id str
    The ID of a public cloud project's user.
    policy String
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName String
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId String
    The ID of a public cloud project's user.

    Outputs

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

    Get an existing S3Policy 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?: S3PolicyState, opts?: CustomResourceOptions): S3Policy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy: Optional[str] = None,
            service_name: Optional[str] = None,
            user_id: Optional[str] = None) -> S3Policy
    func GetS3Policy(ctx *Context, name string, id IDInput, state *S3PolicyState, opts ...ResourceOption) (*S3Policy, error)
    public static S3Policy Get(string name, Input<string> id, S3PolicyState? state, CustomResourceOptions? opts = null)
    public static S3Policy get(String name, Output<String> id, S3PolicyState 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:
    Policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    ServiceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    UserId string
    The ID of a public cloud project's user.
    Policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    ServiceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    UserId string
    The ID of a public cloud project's user.
    policy String
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName String
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId String
    The ID of a public cloud project's user.
    policy string
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName string
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId string
    The ID of a public cloud project's user.
    policy str
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    service_name str
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    user_id str
    The ID of a public cloud project's user.
    policy String
    The policy document. This is a JSON formatted string. See examples of policies on public documentation.
    serviceName String
    The ID of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    userId String
    The ID of a public cloud project's user.

    Import

    OVHcloud User S3 Policy can be imported using the service_name, user_id of the policy, separated by “/” E.g.,

    bash

    $ pulumi import ovh:CloudProject/s3Policy:S3Policy policy service_name/user_id
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    ovh ovh/pulumi-ovh
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the ovh Terraform Provider.
    ovh logo
    OVHCloud v0.45.0 published on Tuesday, Jun 4, 2024 by OVHcloud