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

Support AWS Lambda #415

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/sitemap_generator/adapters/aws_sdk_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ class AwsSdkAdapter
# All other options you provide are passed directly to the AWS client.
# See https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/S3/Client.html#initialize-instance_method
# for a full list of supported options.
def initialize(bucket, aws_access_key_id: nil, aws_secret_access_key: nil, aws_region: nil, aws_endpoint: nil, acl: 'public-read', cache_control: 'private, max-age=0, no-cache', **options)
def initialize(bucket, aws_access_key_id: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_region: nil, aws_endpoint: nil, acl: 'public-read', cache_control: 'private, max-age=0, no-cache', **options)
@bucket = bucket
@acl = acl
@cache_control = cache_control
@options = options
set_option_unless_set(:access_key_id, aws_access_key_id)
set_option_unless_set(:secret_access_key, aws_secret_access_key)
set_option_unless_set(:session_token, aws_session_token)
set_option_unless_set(:region, aws_region)
set_option_unless_set(:endpoint, aws_endpoint)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/sitemap_generator/adapters/s3_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class S3Adapter
def initialize(opts = {})
@aws_access_key_id = opts[:aws_access_key_id] || ENV['AWS_ACCESS_KEY_ID']
@aws_secret_access_key = opts[:aws_secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY']
@aws_session_token = opts[:aws_session_token] || ENV['AWS_SESSION_TOKEN']
@fog_provider = opts[:fog_provider] || ENV['FOG_PROVIDER']
@fog_directory = opts[:fog_directory] || ENV['FOG_DIRECTORY']
@fog_region = opts[:fog_region] || ENV['FOG_REGION']
Expand All @@ -43,6 +44,7 @@ def write(location, raw_data)
if @aws_access_key_id && @aws_secret_access_key
credentials[:aws_access_key_id] = @aws_access_key_id
credentials[:aws_secret_access_key] = @aws_secret_access_key
credentials[:aws_session_token] = @aws_session_token if @aws_session_token
else
credentials[:use_iam_profile] = true
end
Expand Down
2 changes: 2 additions & 0 deletions spec/sitemap_generator/adapters/s3_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{
aws_access_key_id: 'aws_access_key_id',
aws_secret_access_key: 'aws_secret_access_key',
aws_session_token: 'aws_session_token',
fog_provider: 'fog_provider',
fog_directory: 'fog_directory',
fog_region: 'fog_region',
Expand All @@ -51,6 +52,7 @@
it 'sets options on the instance' do
expect(adapter.instance_variable_get(:@aws_access_key_id)).to eq('aws_access_key_id')
expect(adapter.instance_variable_get(:@aws_secret_access_key)).to eq('aws_secret_access_key')
expect(adapter.instance_variable_get(:@aws_session_token)).to eq('aws_session_token')
expect(adapter.instance_variable_get(:@fog_provider)).to eq('fog_provider')
expect(adapter.instance_variable_get(:@fog_directory)).to eq('fog_directory')
expect(adapter.instance_variable_get(:@fog_region)).to eq('fog_region')
Expand Down