s3_website icon indicating copy to clipboard operation
s3_website copied to clipboard

staging and production environment variables

Open tazmaniax opened this issue 9 years ago • 5 comments

Hi,

How do I pass to s3_website on the command line whether it's staging or production environment so that it picks up the dotenv .env.staging or .env.production files respectively? I can't see anything in the documentation.

thanks

tazmaniax avatar May 30 '16 18:05 tazmaniax

Will https://github.com/laurilehmijoki/s3_website#specifying-the-location-of-your-website help you?

laurilehmijoki avatar May 31 '16 03:05 laurilehmijoki

I feel that it would be easier to just have something like --config s3_staging.yml, this way I don't have to create a folder just for a separate configuration

fregante avatar Jun 30 '16 15:06 fregante

This would also be a big help for me too, I will have a separate config for staging/demo that I would prefer to not store in a separate file. Not at all a showstopper as everything else has worked beautifully.

colinjfw avatar Aug 11 '16 00:08 colinjfw

FYI, and in the meantime, I've had good success with this hack in s3_website.yml:

<%
  if ENV['ENV'] == 'production'
    @s3_bucket = '...'
    @cloudfront_id = '...'
  else
    @s3_bucket = '...'
    @cloudfront_id = '...'
  end
%>

...

s3_bucket: <%= @s3_bucket %>

...

cloudfront_distribution_id: <%= @cloudfront_id %>

...

And then you do ENV=production s3_website push or ENV=staging s3_website push

jeromedalbert avatar Apr 13 '17 23:04 jeromedalbert

Hey! Thank you for that.

In case I don't have a CloudFront distribution for the staging environment, would the following work?

<%
  if ENV['ENV'] == 'production'
    @s3_bucket = 'prod.doma.in'
    @cloudfront = 'D1S3BUT10NID'
    @wildcardinv = true
  elsif ENV['ENV'] == 'staging'
    @s3_bucket = 'staging.doma.in'
  else
    @s3_bucket = 'dev.doma.in'
  end
%>
s3_bucket: <%= @s3_bucket %>
cloudfront_distribution_id: <%= @cloudfront %>
cloudfront_wildcard_invalidation: <%= @wildcardinv %>

That would essentially return null values for the distribution and wildcard invalidation on non-production builds. Is that valid?

I've posted this question on StackOverflow as well.

theramiyer avatar Jan 04 '18 08:01 theramiyer