Skip to content

Commit d08c706

Browse files
wangpindeAlena Kastsiukavets
authored andcommitted
Provide a new agent config option to let customers switch ADCS/CDCS client
cr https://code.amazon.com/reviews/CR-24765207
1 parent cd883c7 commit d08c706

File tree

10 files changed

+411
-9
lines changed

10 files changed

+411
-9
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem "codedeploy-commands", "1.0.0", :path => "#{File.expand_path(__FILE__)}/../v
1010

1111
group :test do
1212
gem 'test-unit'
13-
gem 'activesupport', :require => 'active_support'
13+
gem 'activesupport', :require => 'active_support'
1414
gem 'coveralls', require: false
1515
gem 'cucumber'
1616
gem 'fakefs', :require => 'fakefs/safe'

lib/instance_agent/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def initialize
4343
:enable_deployments_log => true,
4444
:use_fips_mode => false,
4545
:deploy_control_endpoint => nil,
46-
:s3_endpoint_override => nil
46+
:s3_endpoint_override => nil,
47+
:enable_auth_policy => false
4748
})
4849
end
4950

lib/instance_agent/plugins/codedeploy/codedeploy_control.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def ssl_verify_peer
4747

4848
def verify_cert_fields
4949
deploy_control_endpoint = get_client.config.endpoint
50+
InstanceAgent::Log.debug("Current deploy control endpoint: #{deploy_control_endpoint}")
5051
begin
5152
cert_verifier = InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier.new(deploy_control_endpoint)
5253
cert_verifier.verify_cert

lib/instance_agent/plugins/codedeploy/command_poller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def initialize
4040

4141
log(:debug, "Configuring deploy control client: Region=#{region.inspect}")
4242
log(:debug, "Deploy control endpoint override=#{InstanceAgent::Config.config[:deploy_control_endpoint]}")
43+
log(:debug, "Enable auth policy = #{InstanceAgent::Config.config[:enable_auth_policy]}")
4344

4445
@deploy_control = InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl.new(:region => region, :logger => InstanceAgent::Log, :ssl_ca_directory => ENV['AWS_SSL_CA_DIRECTORY'])
4546
@deploy_control_client = @deploy_control.get_client

test/instance_agent/config_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class InstanceAgentConfigTest < InstanceAgentTestCase
3434
:kill_agent_max_wait_time_seconds => 7200,
3535
:use_fips_mode => false,
3636
:deploy_control_endpoint => nil,
37-
:s3_endpoint_override => nil
37+
:s3_endpoint_override => nil,
38+
:enable_auth_policy => false
3839
}, InstanceAgent::Config.config)
3940
end
4041

test/instance_agent/plugins/codedeploy/codedeploy_control_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ class CodeDeployControlTest < InstanceAgentTestCase
8383
assert_equal "codedeploy-commands-fips.us-west-2.amazonaws.com", codedeploy_control_client.get_client.config.endpoint.host
8484
end
8585
end
86+
87+
context "with enable_auth_policy set" do
88+
setup do
89+
InstanceAgent::Config.config[:enable_auth_policy] = true
90+
end
91+
92+
should "use secure endpoint" do
93+
codedeploy_control_client = CodeDeployControl.new :region => "us-west-2"
94+
assert_equal "codedeploy-commands-secure.us-west-2.amazonaws.com", codedeploy_control_client.get_client.config.endpoint.host
95+
end
96+
end
97+
98+
context "with both of use_fips_mode and enable_auth_policy set" do
99+
setup do
100+
InstanceAgent::Config.config[:use_fips_mode] = true
101+
InstanceAgent::Config.config[:enable_auth_policy] = true
102+
end
103+
104+
should "use secure Fips endpoint" do
105+
codedeploy_control_client = CodeDeployControl.new :region => "us-west-2"
106+
assert_equal "codedeploy-commands-secure-fips.us-west-2.amazonaws.com", codedeploy_control_client.get_client.config.endpoint.host
107+
end
108+
end
86109

87110
end
88111
end

vendor/gems/codedeploy-commands-1.0.0/apis/CodeDeployCommand.api.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"apiVersion": "2014-10-06",
55
"endpointPrefix": "codedeploy-commands",
66
"jsonVersion": "1.1",
7-
"regionalEndpoints": {
8-
"us-east-1": "codedeploy-commands.us-east-1.amazonaws.com",
9-
"us-west-2": "codedeploy-commands.us-west-2.amazonaws.com"
10-
},
117
"serviceAbbreviation": "CodeDeployCommand",
128
"serviceFullName": "AWS CodeDeploy Command Service",
139
"signatureVersion": "v4",

0 commit comments

Comments
 (0)