Method: Stackr::CloudFormation#upload_to_s3
- Defined in:
- lib/stackr/cloudformation.rb
#upload_to_s3(template_str, name) ⇒ Object
Requires TEMPLATE_BUCKET environment variable to be set. If TEMPLATE_PREFIX environment variable is set, templates will be uploaded using that prefix.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/stackr/cloudformation.rb', line 22 def upload_to_s3(template_str, name) s3 = Aws::S3::Resource.new if ENV['TEMPLATE_BUCKET'].nil? raise Stackr::MissingTemplateBucketError, 'Please set TEMPLATE_BUCKET environment variable before uploading templates to S3.' end bucket = s3.bucket(ENV['TEMPLATE_BUCKET']) key = "#{name}.json" if ENV['TEMPLATE_PREFIX'] key = "#{ENV['TEMPLATE_PREFIX']}/#{key}" end s3_object = bucket.object(key) s3_object.put(body: template_str) return s3_object.public_url end |