1. Packages
  2. Flexibleengine Provider
  3. API Docs
  4. S3BucketPolicy
flexibleengine 1.46.0 published on Monday, Apr 14, 2025 by flexibleenginecloud

flexibleengine.S3BucketPolicy

Explore with Pulumi AI

flexibleengine logo
flexibleengine 1.46.0 published on Monday, Apr 14, 2025 by flexibleenginecloud

    Attaches a policy to an S3 bucket resource.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as flexibleengine from "@pulumi/flexibleengine";
    
    const s3Bucket = new flexibleengine.S3Bucket("s3Bucket", {bucket: "my_tf_test_bucket"});
    const s3BucketPolicy = new flexibleengine.S3BucketPolicy("s3BucketPolicy", {
        bucket: s3Bucket.s3BucketId,
        policy: `{
      "Version": "2012-10-17",
      "Id": "MYBUCKETPOLICY",
      "Statement": [
        {
          "Sid": "IPAllow",
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": "arn:aws:s3:::my_tf_test_bucket/*",
          "Condition": {
             "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
          } 
        } 
      ]
    }
    `,
    });
    
    import pulumi
    import pulumi_flexibleengine as flexibleengine
    
    s3_bucket = flexibleengine.S3Bucket("s3Bucket", bucket="my_tf_test_bucket")
    s3_bucket_policy = flexibleengine.S3BucketPolicy("s3BucketPolicy",
        bucket=s3_bucket.s3_bucket_id,
        policy="""{
      "Version": "2012-10-17",
      "Id": "MYBUCKETPOLICY",
      "Statement": [
        {
          "Sid": "IPAllow",
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": "arn:aws:s3:::my_tf_test_bucket/*",
          "Condition": {
             "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
          } 
        } 
      ]
    }
    """)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/flexibleengine/flexibleengine"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		s3Bucket, err := flexibleengine.NewS3Bucket(ctx, "s3Bucket", &flexibleengine.S3BucketArgs{
    			Bucket: pulumi.String("my_tf_test_bucket"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = flexibleengine.NewS3BucketPolicy(ctx, "s3BucketPolicy", &flexibleengine.S3BucketPolicyArgs{
    			Bucket: s3Bucket.S3BucketId,
    			Policy: pulumi.String(`{
      "Version": "2012-10-17",
      "Id": "MYBUCKETPOLICY",
      "Statement": [
        {
          "Sid": "IPAllow",
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": "arn:aws:s3:::my_tf_test_bucket/*",
          "Condition": {
             "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
          } 
        } 
      ]
    }
    `),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Flexibleengine = Pulumi.Flexibleengine;
    
    return await Deployment.RunAsync(() => 
    {
        var s3Bucket = new Flexibleengine.S3Bucket("s3Bucket", new()
        {
            Bucket = "my_tf_test_bucket",
        });
    
        var s3BucketPolicy = new Flexibleengine.S3BucketPolicy("s3BucketPolicy", new()
        {
            Bucket = s3Bucket.S3BucketId,
            Policy = @"{
      ""Version"": ""2012-10-17"",
      ""Id"": ""MYBUCKETPOLICY"",
      ""Statement"": [
        {
          ""Sid"": ""IPAllow"",
          ""Effect"": ""Deny"",
          ""Principal"": ""*"",
          ""Action"": ""s3:*"",
          ""Resource"": ""arn:aws:s3:::my_tf_test_bucket/*"",
          ""Condition"": {
             ""IpAddress"": {""aws:SourceIp"": ""8.8.8.8/32""}
          } 
        } 
      ]
    }
    ",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.flexibleengine.S3Bucket;
    import com.pulumi.flexibleengine.S3BucketArgs;
    import com.pulumi.flexibleengine.S3BucketPolicy;
    import com.pulumi.flexibleengine.S3BucketPolicyArgs;
    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 s3Bucket = new S3Bucket("s3Bucket", S3BucketArgs.builder()
                .bucket("my_tf_test_bucket")
                .build());
    
            var s3BucketPolicy = new S3BucketPolicy("s3BucketPolicy", S3BucketPolicyArgs.builder()
                .bucket(s3Bucket.s3BucketId())
                .policy("""
    {
      "Version": "2012-10-17",
      "Id": "MYBUCKETPOLICY",
      "Statement": [
        {
          "Sid": "IPAllow",
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": "arn:aws:s3:::my_tf_test_bucket/*",
          "Condition": {
             "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
          } 
        } 
      ]
    }
                """)
                .build());
    
        }
    }
    
    resources:
      s3Bucket:
        type: flexibleengine:S3Bucket
        properties:
          bucket: my_tf_test_bucket
      s3BucketPolicy:
        type: flexibleengine:S3BucketPolicy
        properties:
          bucket: ${s3Bucket.s3BucketId}
          policy: "{\n  \"Version\": \"2012-10-17\",\n  \"Id\": \"MYBUCKETPOLICY\",\n  \"Statement\": [\n    {\n      \"Sid\": \"IPAllow\",\n      \"Effect\": \"Deny\",\n      \"Principal\": \"*\",\n      \"Action\": \"s3:*\",\n      \"Resource\": \"arn:aws:s3:::my_tf_test_bucket/*\",\n      \"Condition\": {\n         \"IpAddress\": {\"aws:SourceIp\": \"8.8.8.8/32\"}\n      } \n    } \n  ]\n}\n"
    

    Create S3BucketPolicy Resource

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

    Constructor syntax

    new S3BucketPolicy(name: string, args: S3BucketPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def S3BucketPolicy(resource_name: str,
                       args: S3BucketPolicyArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def S3BucketPolicy(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       bucket: Optional[str] = None,
                       policy: Optional[str] = None,
                       s3_bucket_policy_id: Optional[str] = None)
    func NewS3BucketPolicy(ctx *Context, name string, args S3BucketPolicyArgs, opts ...ResourceOption) (*S3BucketPolicy, error)
    public S3BucketPolicy(string name, S3BucketPolicyArgs args, CustomResourceOptions? opts = null)
    public S3BucketPolicy(String name, S3BucketPolicyArgs args)
    public S3BucketPolicy(String name, S3BucketPolicyArgs args, CustomResourceOptions options)
    
    type: flexibleengine:S3BucketPolicy
    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 S3BucketPolicyArgs
    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 S3BucketPolicyArgs
    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 S3BucketPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args S3BucketPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args S3BucketPolicyArgs
    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 s3bucketPolicyResource = new Flexibleengine.S3BucketPolicy("s3bucketPolicyResource", new()
    {
        Bucket = "string",
        Policy = "string",
        S3BucketPolicyId = "string",
    });
    
    example, err := flexibleengine.NewS3BucketPolicy(ctx, "s3bucketPolicyResource", &flexibleengine.S3BucketPolicyArgs{
    	Bucket:           pulumi.String("string"),
    	Policy:           pulumi.String("string"),
    	S3BucketPolicyId: pulumi.String("string"),
    })
    
    var s3bucketPolicyResource = new S3BucketPolicy("s3bucketPolicyResource", S3BucketPolicyArgs.builder()
        .bucket("string")
        .policy("string")
        .s3BucketPolicyId("string")
        .build());
    
    s3bucket_policy_resource = flexibleengine.S3BucketPolicy("s3bucketPolicyResource",
        bucket="string",
        policy="string",
        s3_bucket_policy_id="string")
    
    const s3bucketPolicyResource = new flexibleengine.S3BucketPolicy("s3bucketPolicyResource", {
        bucket: "string",
        policy: "string",
        s3BucketPolicyId: "string",
    });
    
    type: flexibleengine:S3BucketPolicy
    properties:
        bucket: string
        policy: string
        s3BucketPolicyId: string
    

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

    Bucket string
    The name of the bucket to which to apply the policy.
    Policy string
    The text of the policy.
    S3BucketPolicyId string
    Bucket string
    The name of the bucket to which to apply the policy.
    Policy string
    The text of the policy.
    S3BucketPolicyId string
    bucket String
    The name of the bucket to which to apply the policy.
    policy String
    The text of the policy.
    s3BucketPolicyId String
    bucket string
    The name of the bucket to which to apply the policy.
    policy string
    The text of the policy.
    s3BucketPolicyId string
    bucket str
    The name of the bucket to which to apply the policy.
    policy str
    The text of the policy.
    s3_bucket_policy_id str
    bucket String
    The name of the bucket to which to apply the policy.
    policy String
    The text of the policy.
    s3BucketPolicyId String

    Outputs

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

    Get an existing S3BucketPolicy 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?: S3BucketPolicyState, opts?: CustomResourceOptions): S3BucketPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            bucket: Optional[str] = None,
            policy: Optional[str] = None,
            s3_bucket_policy_id: Optional[str] = None) -> S3BucketPolicy
    func GetS3BucketPolicy(ctx *Context, name string, id IDInput, state *S3BucketPolicyState, opts ...ResourceOption) (*S3BucketPolicy, error)
    public static S3BucketPolicy Get(string name, Input<string> id, S3BucketPolicyState? state, CustomResourceOptions? opts = null)
    public static S3BucketPolicy get(String name, Output<String> id, S3BucketPolicyState state, CustomResourceOptions options)
    resources:  _:    type: flexibleengine:S3BucketPolicy    get:      id: ${id}
    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:
    Bucket string
    The name of the bucket to which to apply the policy.
    Policy string
    The text of the policy.
    S3BucketPolicyId string
    Bucket string
    The name of the bucket to which to apply the policy.
    Policy string
    The text of the policy.
    S3BucketPolicyId string
    bucket String
    The name of the bucket to which to apply the policy.
    policy String
    The text of the policy.
    s3BucketPolicyId String
    bucket string
    The name of the bucket to which to apply the policy.
    policy string
    The text of the policy.
    s3BucketPolicyId string
    bucket str
    The name of the bucket to which to apply the policy.
    policy str
    The text of the policy.
    s3_bucket_policy_id str
    bucket String
    The name of the bucket to which to apply the policy.
    policy String
    The text of the policy.
    s3BucketPolicyId String

    Package Details

    Repository
    flexibleengine flexibleenginecloud/terraform-provider-flexibleengine
    License
    Notes
    This Pulumi package is based on the flexibleengine Terraform Provider.
    flexibleengine logo
    flexibleengine 1.46.0 published on Monday, Apr 14, 2025 by flexibleenginecloud