alicloud.oss.BucketServerSideEncryption
Explore with Pulumi AI
Provides a OSS Bucket Server Side Encryption resource. Server-side encryption rules of the bucket.
For information about OSS Bucket Server Side Encryption and how to use it, see What is Bucket Server Side Encryption.
NOTE: Available since v1.222.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const createBucket = new alicloud.oss.Bucket("CreateBucket", {
storageClass: "Standard",
bucket: `${name}-${_default.result}`,
});
const getKMS = new alicloud.kms.Key("GetKMS", {
origin: "Aliyun_KMS",
protectionLevel: "SOFTWARE",
description: name,
keySpec: "Aliyun_AES_256",
keyUsage: "ENCRYPT/DECRYPT",
automaticRotation: "Disabled",
pendingWindowInDays: 7,
});
const defaultBucketServerSideEncryption = new alicloud.oss.BucketServerSideEncryption("default", {
kmsDataEncryption: "SM4",
kmsMasterKeyId: getKMS.id,
bucket: createBucket.bucket,
sseAlgorithm: "KMS",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = random.index.Integer("default",
min=10000,
max=99999)
create_bucket = alicloud.oss.Bucket("CreateBucket",
storage_class="Standard",
bucket=f"{name}-{default['result']}")
get_kms = alicloud.kms.Key("GetKMS",
origin="Aliyun_KMS",
protection_level="SOFTWARE",
description=name,
key_spec="Aliyun_AES_256",
key_usage="ENCRYPT/DECRYPT",
automatic_rotation="Disabled",
pending_window_in_days=7)
default_bucket_server_side_encryption = alicloud.oss.BucketServerSideEncryption("default",
kms_data_encryption="SM4",
kms_master_key_id=get_kms.id,
bucket=create_bucket.bucket,
sse_algorithm="KMS")
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/kms"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/oss"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
createBucket, err := oss.NewBucket(ctx, "CreateBucket", &oss.BucketArgs{
StorageClass: pulumi.String("Standard"),
Bucket: pulumi.Sprintf("%v-%v", name, _default.Result),
})
if err != nil {
return err
}
getKMS, err := kms.NewKey(ctx, "GetKMS", &kms.KeyArgs{
Origin: pulumi.String("Aliyun_KMS"),
ProtectionLevel: pulumi.String("SOFTWARE"),
Description: pulumi.String(name),
KeySpec: pulumi.String("Aliyun_AES_256"),
KeyUsage: pulumi.String("ENCRYPT/DECRYPT"),
AutomaticRotation: pulumi.String("Disabled"),
PendingWindowInDays: pulumi.Int(7),
})
if err != nil {
return err
}
_, err = oss.NewBucketServerSideEncryption(ctx, "default", &oss.BucketServerSideEncryptionArgs{
KmsDataEncryption: pulumi.String("SM4"),
KmsMasterKeyId: getKMS.ID(),
Bucket: createBucket.Bucket,
SseAlgorithm: pulumi.String("KMS"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var createBucket = new AliCloud.Oss.Bucket("CreateBucket", new()
{
StorageClass = "Standard",
BucketName = $"{name}-{@default.Result}",
});
var getKMS = new AliCloud.Kms.Key("GetKMS", new()
{
Origin = "Aliyun_KMS",
ProtectionLevel = "SOFTWARE",
Description = name,
KeySpec = "Aliyun_AES_256",
KeyUsage = "ENCRYPT/DECRYPT",
AutomaticRotation = "Disabled",
PendingWindowInDays = 7,
});
var defaultBucketServerSideEncryption = new AliCloud.Oss.BucketServerSideEncryption("default", new()
{
KmsDataEncryption = "SM4",
KmsMasterKeyId = getKMS.Id,
Bucket = createBucket.BucketName,
SseAlgorithm = "KMS",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.oss.Bucket;
import com.pulumi.alicloud.oss.BucketArgs;
import com.pulumi.alicloud.kms.Key;
import com.pulumi.alicloud.kms.KeyArgs;
import com.pulumi.alicloud.oss.BucketServerSideEncryption;
import com.pulumi.alicloud.oss.BucketServerSideEncryptionArgs;
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 config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var default_ = new Integer("default", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var createBucket = new Bucket("createBucket", BucketArgs.builder()
.storageClass("Standard")
.bucket(String.format("%s-%s", name,default_.result()))
.build());
var getKMS = new Key("getKMS", KeyArgs.builder()
.origin("Aliyun_KMS")
.protectionLevel("SOFTWARE")
.description(name)
.keySpec("Aliyun_AES_256")
.keyUsage("ENCRYPT/DECRYPT")
.automaticRotation("Disabled")
.pendingWindowInDays(7)
.build());
var defaultBucketServerSideEncryption = new BucketServerSideEncryption("defaultBucketServerSideEncryption", BucketServerSideEncryptionArgs.builder()
.kmsDataEncryption("SM4")
.kmsMasterKeyId(getKMS.id())
.bucket(createBucket.bucket())
.sseAlgorithm("KMS")
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: random:integer
properties:
min: 10000
max: 99999
createBucket:
type: alicloud:oss:Bucket
name: CreateBucket
properties:
storageClass: Standard
bucket: ${name}-${default.result}
getKMS:
type: alicloud:kms:Key
name: GetKMS
properties:
origin: Aliyun_KMS
protectionLevel: SOFTWARE
description: ${name}
keySpec: Aliyun_AES_256
keyUsage: ENCRYPT/DECRYPT
automaticRotation: Disabled
pendingWindowInDays: 7
defaultBucketServerSideEncryption:
type: alicloud:oss:BucketServerSideEncryption
name: default
properties:
kmsDataEncryption: SM4
kmsMasterKeyId: ${getKMS.id}
bucket: ${createBucket.bucket}
sseAlgorithm: KMS
Create BucketServerSideEncryption Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BucketServerSideEncryption(name: string, args: BucketServerSideEncryptionArgs, opts?: CustomResourceOptions);
@overload
def BucketServerSideEncryption(resource_name: str,
args: BucketServerSideEncryptionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketServerSideEncryption(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
sse_algorithm: Optional[str] = None,
kms_data_encryption: Optional[str] = None,
kms_master_key_id: Optional[str] = None)
func NewBucketServerSideEncryption(ctx *Context, name string, args BucketServerSideEncryptionArgs, opts ...ResourceOption) (*BucketServerSideEncryption, error)
public BucketServerSideEncryption(string name, BucketServerSideEncryptionArgs args, CustomResourceOptions? opts = null)
public BucketServerSideEncryption(String name, BucketServerSideEncryptionArgs args)
public BucketServerSideEncryption(String name, BucketServerSideEncryptionArgs args, CustomResourceOptions options)
type: alicloud:oss:BucketServerSideEncryption
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 BucketServerSideEncryptionArgs
- 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 BucketServerSideEncryptionArgs
- 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 BucketServerSideEncryptionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketServerSideEncryptionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketServerSideEncryptionArgs
- 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 bucketServerSideEncryptionResource = new AliCloud.Oss.BucketServerSideEncryption("bucketServerSideEncryptionResource", new()
{
Bucket = "string",
SseAlgorithm = "string",
KmsDataEncryption = "string",
KmsMasterKeyId = "string",
});
example, err := oss.NewBucketServerSideEncryption(ctx, "bucketServerSideEncryptionResource", &oss.BucketServerSideEncryptionArgs{
Bucket: pulumi.String("string"),
SseAlgorithm: pulumi.String("string"),
KmsDataEncryption: pulumi.String("string"),
KmsMasterKeyId: pulumi.String("string"),
})
var bucketServerSideEncryptionResource = new BucketServerSideEncryption("bucketServerSideEncryptionResource", BucketServerSideEncryptionArgs.builder()
.bucket("string")
.sseAlgorithm("string")
.kmsDataEncryption("string")
.kmsMasterKeyId("string")
.build());
bucket_server_side_encryption_resource = alicloud.oss.BucketServerSideEncryption("bucketServerSideEncryptionResource",
bucket="string",
sse_algorithm="string",
kms_data_encryption="string",
kms_master_key_id="string")
const bucketServerSideEncryptionResource = new alicloud.oss.BucketServerSideEncryption("bucketServerSideEncryptionResource", {
bucket: "string",
sseAlgorithm: "string",
kmsDataEncryption: "string",
kmsMasterKeyId: "string",
});
type: alicloud:oss:BucketServerSideEncryption
properties:
bucket: string
kmsDataEncryption: string
kmsMasterKeyId: string
sseAlgorithm: string
BucketServerSideEncryption 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 BucketServerSideEncryption resource accepts the following input properties:
- Bucket string
- The name of the bucket.
- Sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- Kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- Kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- Bucket string
- The name of the bucket.
- Sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- Kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- Kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- bucket String
- The name of the bucket.
- sse
Algorithm String - The server-side encryption method. Valid Values: KMS, AES256.
- kms
Data StringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master StringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- bucket string
- The name of the bucket.
- sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- bucket str
- The name of the bucket.
- sse_
algorithm str - The server-side encryption method. Valid Values: KMS, AES256.
- kms_
data_ strencryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms_
master_ strkey_ id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- bucket String
- The name of the bucket.
- sse
Algorithm String - The server-side encryption method. Valid Values: KMS, AES256.
- kms
Data StringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master StringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketServerSideEncryption 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 BucketServerSideEncryption Resource
Get an existing BucketServerSideEncryption 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?: BucketServerSideEncryptionState, opts?: CustomResourceOptions): BucketServerSideEncryption
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
kms_data_encryption: Optional[str] = None,
kms_master_key_id: Optional[str] = None,
sse_algorithm: Optional[str] = None) -> BucketServerSideEncryption
func GetBucketServerSideEncryption(ctx *Context, name string, id IDInput, state *BucketServerSideEncryptionState, opts ...ResourceOption) (*BucketServerSideEncryption, error)
public static BucketServerSideEncryption Get(string name, Input<string> id, BucketServerSideEncryptionState? state, CustomResourceOptions? opts = null)
public static BucketServerSideEncryption get(String name, Output<String> id, BucketServerSideEncryptionState 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.
- Bucket string
- The name of the bucket.
- Kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- Kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- Sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- Bucket string
- The name of the bucket.
- Kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- Kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- Sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- bucket String
- The name of the bucket.
- kms
Data StringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master StringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- sse
Algorithm String - The server-side encryption method. Valid Values: KMS, AES256.
- bucket string
- The name of the bucket.
- kms
Data stringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master stringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- sse
Algorithm string - The server-side encryption method. Valid Values: KMS, AES256.
- bucket str
- The name of the bucket.
- kms_
data_ strencryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms_
master_ strkey_ id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- sse_
algorithm str - The server-side encryption method. Valid Values: KMS, AES256.
- bucket String
- The name of the bucket.
- kms
Data StringEncryption - The algorithm used to encrypt objects. If this element is not specified, objects are encrypted by using AES256. This element is valid only when the value of SSEAlgorithm is set to KMS.
- kms
Master StringKey Id - The CMK ID that must be specified when SSEAlgorithm is set to KMS and a specified CMK is used for encryption. In other cases, this element must be set to null.
- sse
Algorithm String - The server-side encryption method. Valid Values: KMS, AES256.
Import
OSS Bucket Server Side Encryption can be imported using the id, e.g.
$ pulumi import alicloud:oss/bucketServerSideEncryption:BucketServerSideEncryption example <id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.