Source: resources/s3.js

  1. 'use strict'
  2. const WKResource = require('./../resource').WKResource
  3. const ResourceAttribute = require('./../resourceattribute').ResourceAttribute
  4. const ResourceAttributeArray = require('./../resourceattribute').ResourceAttributeArray
  5. const tag = require('./../tag')
  6. const types = require('./../types')
  7. /** @module S3 */
  8. /** @memberof module:S3
  9. * @extends WKResource
  10. * @property {String} AccessControl Required: No. A canned access control list (ACL) that grants predefined permissions to the
  11. bucket. For more information about canned ACLs, see Canned ACLs in the
  12. Amazon S3 documentation.Valid values: AuthenticatedRead |
  13. AwsExecRead | BucketOwnerRead |
  14. BucketOwnerFullControl |
  15. LogDeliveryWrite | Private |
  16. PublicRead |
  17. PublicReadWriteUpdate requires: No interruption
  18. * @property {String} BucketName Required: No. A name for the bucket. If you don't specify a name, AWS CloudFormation generates a unique
  19. physical ID and uses that ID for the bucket name. For more information, see Name Type. The bucket
  20. name must contain only lowercase letters, numbers, periods (.), and dashes
  21. (-).ImportantIf you specify a name, you cannot do updates that require this resource to be replaced.
  22. You can still do updates that require no or some interruption. If you must replace the resource, specify a new name.Update requires: Replacement
  23. * @property {AmazonS3CorsConfiguration} CorsConfiguration Required: No. Rules that define cross-origin resource sharing of objects in this bucket.
  24. For more information, see Enabling
  25. Cross-Origin Resource Sharing in the
  26. Amazon Simple Storage Service Developer Guide.Update requires: No interruption
  27. * @property {AmazonS3LifecycleConfiguration} LifecycleConfiguration Required: No. Rules that define how Amazon S3 manages objects during their lifetime. For more
  28. information, see Object
  29. Lifecycle Management in the
  30. Amazon Simple Storage Service Developer Guide.Update requires: No interruption
  31. * @property {AmazonS3LoggingConfiguration} LoggingConfiguration Required: No. Settings that defines where logs are stored.Update requires: No interruption
  32. * @property {AmazonS3NotificationConfiguration} NotificationConfiguration Required: No. Configuration that defines how Amazon S3 handles bucket notifications.Update requires: No interruption
  33. * @property {AmazonS3ReplicationConfiguration} ReplicationConfiguration Required: No. Configuration for replicating objects in an S3 bucket. To enable replication, you
  34. must also enable versioning by using the VersioningConfiguration
  35. property.Amazon S3 can store replicated objects in only one destination (S3 bucket). You cannot
  36. send replicated objects to multiple S3 buckets.Update requires: No interruption
  37. * @property {AWSCloudFormationResourceTags} Tags Required: No. An arbitrary set of tags (key-value pairs) for this Amazon S3 bucket.Update requires: No interruption
  38. * @property {AmazonS3VersioningConfiguration} VersioningConfiguration Required: No. Enables multiple variants of all objects in this bucket. You might enable
  39. versioning to prevent objects from being deleted or overwritten by mistake
  40. or to archive objects so that you can retrieve previous versions of
  41. them.Update requires: No interruption
  42. * @property {AmazonS3WebsiteConfigurationProperty} WebsiteConfiguration Required: No. Information used to configure the bucket as a static website. For more information, see Hosting Websites on Amazon
  43. S3.Update requires: No interruption
  44. */
  45. class Bucket extends WKResource {
  46. constructor (name, propertiesObject) {
  47. let resourceType = 'AWS::S3::Bucket'
  48. let properties = {
  49. AccessControl: new ResourceAttribute('AccessControl', String, 'No', null),
  50. BucketName: new ResourceAttribute('BucketName', String, 'No', null),
  51. CorsConfiguration: new ResourceAttribute('CorsConfiguration', types.AmazonS3CorsConfiguration, 'No', null),
  52. LifecycleConfiguration: new ResourceAttribute('LifecycleConfiguration', types.AmazonS3LifecycleConfiguration, 'No', null),
  53. LoggingConfiguration: new ResourceAttribute('LoggingConfiguration', types.AmazonS3LoggingConfiguration, 'No', null),
  54. NotificationConfiguration: new ResourceAttribute('NotificationConfiguration', types.AmazonS3NotificationConfiguration, 'No', null),
  55. ReplicationConfiguration: new ResourceAttribute('ReplicationConfiguration', types.AmazonS3ReplicationConfiguration, 'No', null),
  56. Tags: new tag.TagSet(),
  57. VersioningConfiguration: new ResourceAttribute('VersioningConfiguration', types.AmazonS3VersioningConfiguration, 'No', null),
  58. WebsiteConfiguration: new ResourceAttribute('WebsiteConfiguration', types.AmazonS3WebsiteConfigurationProperty, 'No', null)
  59. }
  60. super(name, resourceType, properties, propertiesObject)
  61. }
  62. }
  63. /** @memberof module:S3
  64. * @extends WKResource
  65. * @property {String} Bucket Required: Yes. The Amazon S3 bucket that the policy applies to.You cannot update this property. If you want to add or remove a bucket from a
  66. bucket policy, you must modify your AWS CloudFormation template by creating a new bucket policy
  67. resource and removing the old one. Then use the modified template to update your AWS CloudFormation
  68. stack.
  69. * @property {Object} PolicyDocument Required: Yes. A policy document containing permissions to add to the specified bucket. For
  70. more information, see Access Policy Language Overview in the
  71. Amazon Simple Storage Service Developer Guide.Update requires: No interruption
  72. */
  73. class BucketPolicy extends WKResource {
  74. constructor (name, propertiesObject) {
  75. let resourceType = 'AWS::S3::BucketPolicy'
  76. let properties = {
  77. Bucket: new ResourceAttribute('Bucket', String, 'Yes', null),
  78. PolicyDocument: new ResourceAttribute('PolicyDocument', Object, 'Yes', null)
  79. }
  80. super(name, resourceType, properties, propertiesObject)
  81. }
  82. }
  83. module.exports = { Bucket: Bucket,
  84. BucketPolicy: BucketPolicy
  85. }