edit-icon download-icon

ALIYUN::OSS::Bucket

Last Updated: Mar 23, 2018

The ALIYUN::OSS::Bucket type is used to create an OSS bucket.

Syntax

  1. {
  2. "Type" : "ALIYUN::OSS::Bucket",
  3. "Properties" : {
  4. "BucketName" : String,
  5. "AccessControl" : String,
  6. "CORSConfiguration" : Map,
  7. "LifecycleConfiguration " : Map,
  8. "LoggingConfiguration" : Map,
  9. "RefererConfiguration" : Map,
  10. "WebsiteConfiguration" : Map
  11. }
  12. }

Attributes

Attribute name Type Required? Description Constraint
BucketName string Yes Bucket name. The bucket name is a string of 3 to 63 characters and can contain only lowercase letters, digits, and underscores(_). It must start and end with a lowercase letter or digit.
AccessControl string No Access permission. Value options: private, public-read, and public-read-write.
CORSConfiguration. map No Cross-origin access configuration. N/A
LifecycleConfiguration. map No File lifecycle configuration. N/A
LoggingConfiguration map No Log storage configuration. N/A
RefererConfiguration map No Referer configuration. N/A
WebsiteConfiguration map No Static hosting page configuration. N/A

CORSConfiguration syntax

  1. "CORSConfiguration": {
  2. "CORSRule": [
  3. {
  4. "AllowedHeader" : String,
  5. "AllowedMethod" : List,
  6. "AllowedOrigin" : List,
  7. "ExposeHeader" : List,
  8. "MaxAgeSeconds" : Integer
  9. }
  10. ]
  11. }

CORSConfiguration attributes

Attribute name Type Required? Description Constraint
CORSRule list No Multiple cross-origin access rules. N/A
AllowedHeader string No Cross-origin access request header. Value options: *, Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, and Pragma.
AllowedMethod list No Cross-origin access request method. Value options: *, GET, PUT, POST, DELETE, HEAD.
AllowedOrigin list No Cross-origin access request source. N/A
ExposeHeader list No Response header that users are allowed to access from an application (for example, a JavaScript XMLHttpRequest object). N/A
MaxAgeSeconds integer No Cache time for the returned results of browser prefetching (OPTIONS) requests for a specific resource. N/A

LifecycleConfiguration syntax

  1. "LifecycleConfiguration": {
  2. "Rule": [
  3. {
  4. "ID": String,
  5. "Prefix" : String,
  6. "Status" : String,
  7. "Expiration" :{
  8. "Days" : Integer,
  9. "CreatedBeforeDate" : String
  10. },
  11. "AbortMultipartUpload" : {
  12. "CreatedBeforeDate": String,
  13. "Days" : String
  14. }
  15. }
  16. ]
  17. }

LifecycleConfiguration attributes

Attribute name Type Required? Description Constraint
Rule list No Lifecycle rule. N/A
ID string No Unique rule ID. The ID can contain a maximum of 255 bytes. When this parameter is unspecified or null, OSS generates a unique rule ID.
Prefix string No Prefix applicable to the lifecycle rule. The rule takes effect only for the objects that match the prefix. Overlapping prefixes are not allowed.
Status string No Whether to enable or disable the lifecycle rule. Value options: Enable and Disable.
Expiration map No Object rule expiration attribute. N/A
Days string No Number of days after which the rule takes effect following the last object modification time. When the number of days from the last modification time of the object exceeds the specified number of days, the rule is executed to delete the object. For example, if it is set to 30 days, the objects whose last modification date is January 1, 2016 are scanned and deleted by the backend program on January 31, 2016.
CreatedBeforeDate string No Date before which the rule takes effect. The date must follow the ISO8601 format and always be UTC 00:00 AM, for example, 2002-10-11T00:00:00.000Z.
AbortMultipartUpload map No Expiration time. N/A

LoggingConfiguration syntax

  1. "LoggingConfiguration": {
  2. "TargetBucket": String,
  3. "TargetPrefix": String
  4. }

LoggingConfiguration attributes

Attribute name Type Required? Description Constraint
TargetBucket string No Bucket that stores access logs. N/A
TargetPrefix string No Prefix of the name of the finally saved access log file. N/A

WebsiteConfiguration syntax

  1. "WebsiteConfiguration":{
  2. "IndexDocument": String,
  3. "ErrorDocument": String
  4. }

WebsiteConfiguration attributes

Attribute name Type Required? Description Constraint
IndexDocument string No Static homepage. N/A
ErrorDocument string No Static error page. N/A

RefererConfiguration syntax

  1. "RefererConfiguration":{
  2. "AllowEmptyReferer": String,
  3. "RefererList": List
  4. }

RefererConfiguration attributes

Attribute name Type Required? Description Constraint
AllowEmptyReferer string No Whether to allow access requests with a null referer field. N/A
RefererList list No Whitelist of allowed referers. N/A

Return values

Fn::GetAtt

  • Name: bucket name, which is globally unique.

  • DomainName: domain name used by bucket access.

Example

  1. {
  2. "ROSTemplateFormatVersion" : "2015-09-01",
  3. "Resources" : {
  4. "Bucket": {
  5. "Type": "ALIYUN::OSS::Bucket",
  6. "Properties": {
  7. "AccessControl": "private",
  8. "BucketName": "rostest",
  9. "WebsiteConfiguration":{
  10. "IndexDocument": "index1.html",
  11. "ErrorDocument": "error404.html"
  12. },
  13. "LoggingConfiguration": {
  14. "TargetBucket": "cos-mirror",
  15. "TargetPrefix": "test404"
  16. },
  17. "CORSConfiguration": {
  18. "CORSRule": [{
  19. "AllowedHeader": ["*"],
  20. "AllowedMethod": ["GET", "PUT"],
  21. "AllowedOrigin": ["*"],
  22. "ExposeHeader": ["Date"],
  23. "MaxAgeSeconds": 3600
  24. }]
  25. },
  26. "LifecycleConfiguration": {
  27. "Rule": [{
  28. "ID": "deleteRule",
  29. "Prefix": "test/",
  30. "Status": "Enabled",
  31. "Expiration":{
  32. "Days": 2
  33. },
  34. "AbortMultipartUpload":{
  35. "CreatedBeforeDate": "2014-10-11T00:00:00.000Z"
  36. }
  37. }]
  38. },
  39. "RefererConfiguration": {
  40. "AllowEmptyReferer": true,
  41. "RefererList": ["http://www.aliyun.com", "https://www.?.aliyuncs.com"]
  42. }
  43. }
  44. }
  45. },
  46. "Outputs": {
  47. "Name": {
  48. "Value" : {"Fn::GetAtt": ["Bucket","Name"]}
  49. },
  50. "DomainName": {
  51. "Value" : {"Fn::GetAtt": ["Bucket","DomainName"]}
  52. }
  53. }
  54. }
Thank you! We've received your feedback.