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

Deploy layer to any AWS Region #5

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions aws-lambda-layer/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require 'fileutils'

BUILD_DIR = File.join(__dir__, 'build')
DEFAULT_FREETDS_VERSION = '1.1.6'
DEFAULT_AWS_REGION = ENV['AWS_REGION'] || 'us-east-1'

desc 'Build FreeTDS AWS Lambda Layer'
task :build, [:freetds_version] do |_t, args|
Expand All @@ -30,19 +31,21 @@ task :build, [:freetds_version] do |_t, args|
end

desc 'Build FreeTDS AWS Lambda Layer'
task :deploy, [:freetds_version] => [:build] do |_t, args|
task :deploy, [:freetds_version, :aws_region] => [:build] do |_t, args|
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we have an env var for this, do we also need a task parameter? I think it would probably best to just have one way to control this. The current iteration sets up a weird conflict, eg what does this mean: AWS_REGION=whatever bundle exec rake deploy[1.1.6, some_other_region].

I realize we also have that conflict with the freetds version parameter, but that makes it worse somehow.


How about this: for now, either:

  1. make it work exactly like the freetds version stuff. (hard code a const, at the top, then do a 3 layer coalesce for the effective value)
  2. refactor both parameters to be exclusively env vars or task params but not both

Copy link
Contributor

Choose a reason for hiding this comment

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

I realize I recommended splitting the coalescing in a prior review, but that's because I didn't realize what we were doing with freetds version at the time 🤷‍♂️🤦‍♂️

version = args[:freetds_version] || ENV['FREETDS_VERSION'] || DEFAULT_FREETDS_VERSION
aws_region = args[:aws_region] || DEFAULT_AWS_REGION

system("
aws lambda publish-layer-version \
--layer-name 'freetds' \
--description 'FreeTDS #{version} Layer' \
--region 'us-east-1' \
--region #{aws_region} \
--zip-file \"fileb://$(pwd)/build/freetds-layer-#{version}.zip\"
")
end

desc 'List available FreeTDS AWS Lambda Layers'
task :list_layers do |_t, args|
system('aws lambda list-layers --region us-east-1')
task :list_layers, [:aws_region] do |_t, args|
aws_region = args[:aws_region] || DEFAULT_AWS_REGION
system("aws lambda list-layers --region #{aws_region}")
end