Class: Jets::Cfn::Resource::S3::JetsBucket
- Extended by:
- AwsServices
- Defined in:
- lib/jets/cfn/resource/s3/jets_bucket.rb
Constant Summary collapse
- @@name =
nil
Instance Attribute Summary
Attributes inherited from Bucket
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ JetsBucket
constructor
A new instance of JetsBucket.
- #props ⇒ Object
Methods included from AwsServices
apigateway, aws_options, cfn, codebuild, dynamodb, lambda_client, logs, s3, s3_resource, sns, sqs, ssm, sts, wafv2
Methods included from AwsServices::StackStatus
Methods included from AwsServices::GlobalMemoist
Methods inherited from Bucket
Methods inherited from Base
#attributes, #config, #logical_id, #normalize_tags, #outputs, #parameters, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type
Methods included from Util::Camelize
Methods included from Util::Logging
Constructor Details
#initialize ⇒ JetsBucket
Returns a new instance of JetsBucket.
3 4 5 6 |
# File 'lib/jets/cfn/resource/s3/jets_bucket.rb', line 3 def initialize @bucket_logical_id = "S3Bucket" @props = props end |
Class Method Details
.name ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jets/cfn/resource/s3/jets_bucket.rb', line 38 def name return @@name if @@name return "fake-bucket" if ENV["JETS_NO_INTERNET"] || ENV["JETS_TEMPLATES"] resp = nil begin resp = cfn.describe_stacks(stack_name: Jets::Names.parent_stack_name) rescue Aws::CloudFormation::Errors::ValidationError => e if e..include?("does not exist") return "no-bucket-yet" # for jets build without s3 bucket yet else raise end end output = resp.stacks[0].outputs.find { |o| o.output_key == "S3Bucket" } # The output can be nil if the stack failed and is in rollback state @@name = output.output_value if output # cache only once found end |
Instance Method Details
#props ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jets/cfn/resource/s3/jets_bucket.rb', line 8 def props props = { PublicAccessBlockConfiguration: { BlockPublicAcls: false # BlockPublicPolicy: false, # IgnorePublicAcls: false, # RestrictPublicBuckets: false }, OwnershipControls: { Rules: [{ObjectOwnership: "ObjectWriter"}] }, BucketEncryption: { ServerSideEncryptionConfiguration: [ ServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" } ] } } # CorsConfiguration to allow assets to serve from the bucket props[:CorsConfiguration] = Jets.bootstrap.config.s3_bucket.cors_configuration props end |