Skip to content
Merged

1.7.x #405

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
5 changes: 3 additions & 2 deletions codedeploy_agent.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'aws_codedeploy_agent'
spec.version = '1.7.0'
spec.version = '1.7.1'
spec.summary = 'Packages AWS CodeDeploy agent libraries'
spec.description = 'AWS CodeDeploy agent is responsible for doing the actual work of deploying software on an individual EC2 instance'
spec.author = 'Amazon Web Services'
Expand All @@ -13,13 +13,14 @@ Gem::Specification.new do |spec|

spec.add_dependency('gli', '~> 2.21')
spec.add_dependency('json_pure', '~> 1.6')
spec.add_dependency('archive-tar-minitar', '~> 0.5.2')
spec.add_dependency('minitar', '~> 0.6.1')
spec.add_dependency('rubyzip', '~> 1.3.0')
spec.add_dependency('logging', '~> 2.2')
spec.add_dependency('aws-sdk-core', '~> 3')
spec.add_dependency('aws-sdk-s3', '~> 1')
spec.add_dependency('docopt', '~> 0.5.0')
spec.add_dependency('concurrent-ruby', '~> 1.1.9')
spec.add_dependency('rexml', '~> 3.3.9')

spec.add_development_dependency('rake', '~> 12.3.3')
spec.add_development_dependency('rspec', '~> 3.2.0')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'aws-sdk-core'
require 'json'

module Aws
module Plugins
Expand All @@ -20,10 +21,29 @@ class DeployControlEndpoint < Seahorse::Client::Plugin
if InstanceMetadata.imds_supported?
region = InstanceMetadata.region
domain = InstanceMetadata.domain

if is_on_prem?
partitions_region_pattern = File.read(File.join(File.dirname(__FILE__), 'partition-region-pattern.json'))
partitions_region_pattern_hash = JSON.parse(partitions_region_pattern)

unless partitions_region_pattern_hash.include?(domain)
raise "Unknown domain: #{domain}"
end

known_region_pattern = partitions_region_pattern_hash[domain]["regionRegex"]

unless region.match(known_region_pattern)
raise "Invalid region: #{region}"
end
end

ProcessManager::Log.info("Creating client url from IMDS region and domain")
else
region = cfg.region
domain = 'amazonaws.com'
domain += '.cn' if region.split("-")[0] == 'cn'

ProcessManager::Log.info("Creating client url from configurations")
end

url = "https://#{service}.#{region}.#{domain}"
Expand All @@ -32,6 +52,10 @@ class DeployControlEndpoint < Seahorse::Client::Plugin
ProcessManager::Log.info("CodeDeploy endpoint: #{url}")
url
end

def self.is_on_prem?
return File.readable?(InstanceAgent::Config.config[:on_premises_config_file])
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"amazonaws.com": {
"regionRegex" : "^[0-9a-z-]{1,20}$"
},

"amazonaws.com.cn": {
"regionRegex" : "^cn\\-\\w+\\-\\d+$"
}
}
Loading