Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to ENV vars for AWS credentials #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/middleman-cloudfront/extension.rb
Expand Up @@ -7,8 +7,8 @@ class Extension < Middleman::Extension
# @param [Symbol] key The name of the option
# @param [Object] default The default value for the option
# @param [String] description A human-readable description of what the option does
option :access_key_id, nil, 'Access key id'
option :secret_access_key, nil, 'Secret access key'
option :access_key_id, ENV['AWS_ACCESS_KEY_ID'], 'Access key id'
option :secret_access_key, ENV['AWS_SECRET_ACCESS_KEY'], 'Secret access key'
option :distribution_id, nil, 'Distribution id'
option :filter, /.*/, 'Filter files to be invalidated'
option :after_build, false, 'Invalidate after build'
Expand All @@ -20,6 +20,11 @@ def initialize(app, options_hash={}, &block)
def after_build
Middleman::Cli::CloudFront::Invalidate.new.invalidate(options) if options.after_build
end

def after_configuration
options.access_key_id ||= ENV['AWS_ACCESS_KEY_ID']
options.secret_access_key ||= ENV['AWS_SECRET_ACCESS_KEY']
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed if we already set the defaults as arguments to option above?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the defaults above didn't actually work. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? 😮 Could you add a test for that please?


helpers do
def invalidate(files = nil)
Expand Down