Skip to content

RUBY-3275 backport CI changes to 2.18 #2727

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

Merged
merged 20 commits into from
Jul 3, 2023
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
1 change: 1 addition & 0 deletions .evergreen/auth_aws
102 changes: 62 additions & 40 deletions .evergreen/aws
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,32 @@ $: << File.join(File.dirname(__FILE__), '../spec')
require 'support/aws_utils'
require 'optparse'

options = {}
OptionParser.new do |opts|
opts.banner = "Usage: aws [options] command ..."
def parse_options
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: aws [options] command ..."

opts.on("-a", "--access-key-id=ID", "AWS access key ID") do |v|
options[:access_key_id] = v
end

opts.on("-s", "--secret-access-key=SECRET", "AWS secret access key") do |v|
options[:secret_access_key] = v
end
opts.on("-a", "--access-key-id=ID", "AWS access key ID") do |v|
options[:access_key_id] = v
end

opts.on("-r", "--region=REGION", "AWS region") do |v|
options[:region] = v
end
opts.on("-s", "--secret-access-key=SECRET", "AWS secret access key") do |v|
options[:secret_access_key] = v
end

# launch-ecs options
opts.on('--ec2', 'Use EC2 launch type instead of Fargate') do |v|
options[:ec2] = true
end
end.parse!
opts.on("-r", "--region=REGION", "AWS region") do |v|
options[:region] = v
end

case cmd = ARGV.shift
when 'setup-resources'
AwsUtils::Provisioner.new.setup_aws_auth_resources
when 'reset-keys'
AwsUtils::Provisioner.new.reset_keys
when 'assume-role'
arn = ARGV.shift
# launch-ecs options
opts.on('--ec2', 'Use EC2 launch type instead of Fargate') do |v|
options[:ec2] = true
end
end.parse!
options
end

def assume_role(arn, options)
orchestrator = AwsUtils::Orchestrator.new(**options)
if arn.nil?
arn = AwsUtils::Inspector.new(**options).assume_role_arn
Expand All @@ -43,39 +39,36 @@ when 'assume-role'
puts "AWS_ACCESS_KEY_ID=#{credentials.access_key_id}"
puts "AWS_SECRET_ACCESS_KEY=#{credentials.secret_access_key}"
puts "AWS_SESSION_TOKEN=#{credentials.session_token}"
#puts "EXPIRATION=#{credentials.expiration.utc.strftime('%Y%m%dT%H%M%SZ')}"
puts
when 'set-instance-profile'
instance_id = ARGV.shift
end

def set_instance_profile(instance_id, options)
unless instance_id
raise 'Instance id is required'
end

orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.set_instance_profile(instance_id)
when 'clear-instance-profile'
instance_id = ARGV.shift
end

def clear_instance_profile(instance_id, options)
unless instance_id
raise 'Instance id is required'
end

orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.clear_instance_profile(instance_id)
when 'key-pairs'
AwsUtils::Inspector.new(**options).list_key_pairs
when 'launch-ec2'
public_key_path, = ARGV
end

def launch_ec2(public_key_path, options)
unless public_key_path
raise "Public key path must be given"
end

orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.provision_auth_ec2_instance(public_key_path: public_key_path)
when 'stop-ec2'
orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.terminate_auth_ec2_instance
when 'launch-ecs'
public_key_path, = ARGV
end

def launch_ecs(public_key_path, options)
unless public_key_path
raise "Public key path must be given"
end
Expand All @@ -84,6 +77,35 @@ when 'launch-ecs'
orchestrator.provision_auth_ecs_task(
public_key_path: public_key_path,
)
end

options = parse_options

case cmd = ARGV.shift
when 'setup-resources'
AwsUtils::Provisioner.new.setup_aws_auth_resources
when 'reset-keys'
AwsUtils::Provisioner.new.reset_keys
when 'assume-role'
arn = ARGV.shift
assume_role(arn, options)
when 'set-instance-profile'
instance_id = ARGV.shift
set_instance_profile(instance_id, options)
when 'clear-instance-profile'
instance_id = ARGV.shift
clear_instance_profile(instance_id, options)
when 'key-pairs'
AwsUtils::Inspector.new(**options).list_key_pairs
when 'launch-ec2'
public_key_path, = ARGV
launch_ec2(public_key_path, options)
when 'stop-ec2'
orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.terminate_auth_ec2_instance
when 'launch-ecs'
public_key_path, = ARGV
launch_ecs(public_key_path, options)
when 'stop-ecs'
orchestrator = AwsUtils::Orchestrator.new(**options)
orchestrator.terminate_auth_ecs_task
Expand Down
Loading