Skip to content

Commit

Permalink
Merge branch 'release-1.32.116'
Browse files Browse the repository at this point in the history
* release-1.32.116:
  Bumping version to 1.32.116
  Update changelog based on model updates
  Merge customizations for Bedrock Runtime
  Add changelog entry
  Update to only pass profile parameter in command to session manager plugin
  • Loading branch information
aws-sdk-python-automation committed May 30, 2024
2 parents 047964e + d2f41f5 commit 20a75d5
Show file tree
Hide file tree
Showing 10 changed files with 334 additions and 32 deletions.
47 changes: 47 additions & 0 deletions .changes/1.32.116.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"category": "``acm``",
"description": "add v2 smoke tests and smithy smokeTests trait for SDK testing.",
"type": "api-change"
},
{
"category": "``bedrock-agent``",
"description": "With this release, Knowledge bases for Bedrock adds support for Titan Text Embedding v2.",
"type": "api-change"
},
{
"category": "``bedrock-runtime``",
"description": "This release adds Converse and ConverseStream APIs to Bedrock Runtime",
"type": "api-change"
},
{
"category": "``cloudtrail``",
"description": "CloudTrail Lake returns PartitionKeys in the GetEventDataStore API response. Events are grouped into partitions based on these keys for better query performance. For example, the calendarday key groups events by day, while combining the calendarday key with the hour key groups them by day and hour.",
"type": "api-change"
},
{
"category": "``connect``",
"description": "Adding associatedQueueIds as a SearchCriteria and response field to the SearchRoutingProfiles API",
"type": "api-change"
},
{
"category": "``emr-serverless``",
"description": "The release adds support for spark structured streaming.",
"type": "api-change"
},
{
"category": "``rds``",
"description": "Updates Amazon RDS documentation for Aurora Postgres DBname.",
"type": "api-change"
},
{
"category": "``sagemaker``",
"description": "Adds Model Card information as a new component to Model Package. Autopilot launches algorithm selection for TimeSeries modality to generate AutoML candidates per algorithm.",
"type": "api-change"
},
{
"category": "``ssm start-session``",
"description": "Only provide profile name to session-manager-plugin if provided using --profile flag",
"type": "bugfix"
}
]
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
CHANGELOG
=========

1.32.116
========

* api-change:``acm``: add v2 smoke tests and smithy smokeTests trait for SDK testing.
* api-change:``bedrock-agent``: With this release, Knowledge bases for Bedrock adds support for Titan Text Embedding v2.
* api-change:``bedrock-runtime``: This release adds Converse and ConverseStream APIs to Bedrock Runtime
* api-change:``cloudtrail``: CloudTrail Lake returns PartitionKeys in the GetEventDataStore API response. Events are grouped into partitions based on these keys for better query performance. For example, the calendarday key groups events by day, while combining the calendarday key with the hour key groups them by day and hour.
* api-change:``connect``: Adding associatedQueueIds as a SearchCriteria and response field to the SearchRoutingProfiles API
* api-change:``emr-serverless``: The release adds support for spark structured streaming.
* api-change:``rds``: Updates Amazon RDS documentation for Aurora Postgres DBname.
* api-change:``sagemaker``: Adds Model Card information as a new component to Model Package. Autopilot launches algorithm selection for TimeSeries modality to generate AutoML candidates per algorithm.
* bugfix:``ssm start-session``: Only provide profile name to session-manager-plugin if provided using --profile flag


1.32.115
========

Expand Down
2 changes: 1 addition & 1 deletion awscli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""
import os

__version__ = '1.32.115'
__version__ = '1.32.116'

#
# Get our data path to be added to botocore's search path
Expand Down
3 changes: 2 additions & 1 deletion awscli/customizations/removals.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def register_removals(event_handler):
cmd_remover.remove(on_event='building-command-table.sagemaker-runtime',
remove_commands=['invoke-endpoint-with-response-stream'])
cmd_remover.remove(on_event='building-command-table.bedrock-runtime',
remove_commands=['invoke-model-with-response-stream'])
remove_commands=['invoke-model-with-response-stream',
'converse-stream'])
cmd_remover.remove(on_event='building-command-table.bedrock-agent-runtime',
remove_commands=['invoke-agent'])
cmd_remover.remove(on_event='building-command-table.logs',
Expand Down
9 changes: 5 additions & 4 deletions awscli/customizations/sessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ def invoke(self, service_name, operation_name, parameters,
response = client.start_session(**parameters)
session_id = response['SessionId']
region_name = client.meta.region_name
# profile_name is used to passed on to session manager plugin
# Profile_name is used to passed on to session manager plugin
# to fetch same profile credentials to make an api call in the plugin.
# If no profile is passed then pass on empty string
profile_name = self._session.profile \
if self._session.profile is not None else ''
# If --profile flag is configured, pass it to Session Manager plugin.
# If not, set empty string.
profile_name = parsed_globals.profile \
if parsed_globals.profile is not None else ''
endpoint_url = client.meta.endpoint_url
ssm_env_name = self.DEFAULT_SSM_ENV_NAME

Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# The short X.Y version.
version = '1.32.1'
# The full version, including alpha/beta/rc tags.
release = '1.32.115'
release = '1.32.116'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ universal = 0

[metadata]
requires_dist =
botocore==1.34.115
botocore==1.34.116
docutils>=0.10,<0.17
s3transfer>=0.10.0,<0.11.0
PyYAML>=3.10,<6.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def find_version(*file_paths):


install_requires = [
'botocore==1.34.115',
'botocore==1.34.116',
'docutils>=0.10,<0.17',
's3transfer>=0.10.0,<0.11.0',
'PyYAML>=3.10,<6.1',
Expand Down
216 changes: 214 additions & 2 deletions tests/functional/ssm/test_start_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

from awscli.testutils import BaseAWSCommandParamsTest
from awscli.testutils import BaseAWSHelpOutputTest
from awscli.testutils import mock
from awscli.testutils import create_clidriver, mock, temporary_file
from botocore.exceptions import ProfileNotFound


class TestSessionManager(BaseAWSCommandParamsTest):
Expand All @@ -41,7 +42,7 @@ def test_start_session_success(self, mock_check_output, mock_check_call):
json.dumps(expected_response),
mock.ANY,
"StartSession",
mock.ANY,
"",
json.dumps(start_session_params),
mock.ANY,
],
Expand Down Expand Up @@ -80,13 +81,224 @@ def test_start_session_with_new_version_plugin_success(
ssm_env_name,
mock.ANY,
"StartSession",
"",
json.dumps(start_session_params),
mock.ANY,
],
env=expected_env,
)

@mock.patch("awscli.customizations.sessionmanager.check_call")
@mock.patch("awscli.customizations.sessionmanager.check_output")
def test_profile_parameter_passed_to_sessionmanager_plugin(
self, mock_check_output, mock_check_call
):
cmdline = (
"ssm start-session --target instance-id "
"--profile user_profile"
)
mock_check_call.return_value = 0
mock_check_output.return_value = "1.2.500.0\n"
expected_response = {
"SessionId": "session-id",
"TokenValue": "token-value",
"StreamUrl": "stream-url",
}
self.parsed_responses = [expected_response]
ssm_env_name = "AWS_SSM_START_SESSION_RESPONSE"
start_session_params = {
"Target": "instance-id",
}

# We test this by creating 4 credentials
# env vars, default profile (default),
# env aws profile (local_profile)
# and StartSession command profile (user_profile)
# We want to make sure only profile name in command
# be set to session manager plugin as parameter
self.environ['AWS_ACCESS_KEY_ID'] = 'env_var_akid'
self.environ['AWS_SECRET_ACCESS_KEY'] = 'env_var_sak'

with temporary_file('w') as f:
f.write(
'[default]\n'
'aws_access_key_id = shared_default_akid\n'
'aws_secret_access_key = shared_default_sak\n'
'[local_profile]\n'
'aws_access_key_id = shared_local_akid\n'
'aws_secret_access_key = shared_local_sak\n'
'[user_profile]\n'
'aws_access_key_id = shared_user_akid\n'
'aws_secret_access_key = shared_user_sak\n'
)
f.flush()

self.environ['AWS_SHARED_CREDENTIALS_FILE'] = f.name
self.environ["AWS_PROFILE"] = "local_profile"

expected_env = self.environ.copy()
expected_env.update({ssm_env_name: json.dumps(expected_response)})

self.driver = create_clidriver()
self.run_cmd(cmdline, expected_rc=0)

self.assertEqual(self.operations_called[0][0].name,
'StartSession')
self.assertEqual(self.operations_called[0][1],
{'Target': 'instance-id'})
mock_check_call.assert_called_once_with(
[
"session-manager-plugin",
ssm_env_name,
mock.ANY,
"StartSession",
"user_profile",
json.dumps(start_session_params),
mock.ANY,
],
env=expected_env,
)

@mock.patch("awscli.customizations.sessionmanager.check_call")
@mock.patch("awscli.customizations.sessionmanager.check_output")
def test_profile_environment_not_passed_to_sessionmanager_plugin(
self, mock_check_output, mock_check_call
):
cmdline = "ssm start-session --target instance-id"
mock_check_call.return_value = 0
mock_check_output.return_value = "1.2.500.0\n"
expected_response = {
"SessionId": "session-id",
"TokenValue": "token-value",
"StreamUrl": "stream-url",
}
self.parsed_responses = [expected_response]
ssm_env_name = "AWS_SSM_START_SESSION_RESPONSE"
start_session_params = {
"Target": "instance-id",
}

with temporary_file('w') as f:
f.write(
'[default]\n'
'aws_access_key_id = shared_default_akid\n'
'aws_secret_access_key = shared_default_sak\n'
'[local_profile]\n'
'aws_access_key_id = shared_local_akid\n'
'aws_secret_access_key = shared_local_sak\n'
)
f.flush()

self.environ.pop("AWS_ACCESS_KEY_ID", None)
self.environ.pop("AWS_SECRET_ACCESS_KEY", None)
self.environ['AWS_SHARED_CREDENTIALS_FILE'] = f.name
self.environ["AWS_PROFILE"] = "local_profile"

expected_env = self.environ.copy()
expected_env.update({ssm_env_name: json.dumps(expected_response)})

self.driver = create_clidriver()
self.run_cmd(cmdline, expected_rc=0)

self.assertEqual(self.operations_called[0][0].name,
'StartSession')
self.assertEqual(self.operations_called[0][1],
{'Target': 'instance-id'})
mock_check_call.assert_called_once_with(
[
"session-manager-plugin",
ssm_env_name,
mock.ANY,
"StartSession",
"",
json.dumps(start_session_params),
mock.ANY,
],
env=expected_env,
)

@mock.patch("awscli.customizations.sessionmanager.check_call")
@mock.patch("awscli.customizations.sessionmanager.check_output")
def test_default_profile_used_and_not_passed_to_sessionmanager_plugin(
self, mock_check_output, mock_check_call
):
cmdline = "ssm start-session --target instance-id"
mock_check_call.return_value = 0
mock_check_output.return_value = "1.2.500.0\n"
expected_response = {
"SessionId": "session-id",
"TokenValue": "token-value",
"StreamUrl": "stream-url",
}
self.parsed_responses = [expected_response]
ssm_env_name = "AWS_SSM_START_SESSION_RESPONSE"
start_session_params = {
"Target": "instance-id",
}

with temporary_file('w') as f:
f.write(
'[default]\n'
'aws_access_key_id = shared_default_akid\n'
'aws_secret_access_key = shared_default_sak\n'
)
f.flush()

self.environ.pop("AWS_ACCESS_KEY_ID", None)
self.environ.pop("AWS_SECRET_ACCESS_KEY", None)
self.environ.pop("AWS_SHARED_CREDENTIALS_FILE", None)
self.environ.pop("AWS_PROFILE", None)

expected_env = self.environ.copy()
expected_env.update({ssm_env_name: json.dumps(expected_response)})

self.driver = create_clidriver()
self.run_cmd(cmdline, expected_rc=0)

self.assertEqual(self.operations_called[0][0].name,
'StartSession')
self.assertEqual(self.operations_called[0][1],
{'Target': 'instance-id'})
mock_check_call.assert_called_once_with(
[
"session-manager-plugin",
ssm_env_name,
mock.ANY,
"StartSession",
"",
json.dumps(start_session_params),
mock.ANY,
],
env=expected_env,
)

def test_start_session_with_user_profile_not_exist(self):
cmdline = (
"ssm start-session --target instance-id "
"--profile user_profile"
)
with temporary_file('w') as f:
f.write(
'[default]\n'
'aws_access_key_id = shared_default_akid\n'
'aws_secret_access_key = shared_default_sak\n'
)
f.flush()

self.environ.pop("AWS_ACCESS_KEY_ID", None)
self.environ.pop("AWS_SECRET_ACCESS_KEY", None)
self.environ.pop("AWS_PROFILE", None)
self.environ['AWS_SHARED_CREDENTIALS_FILE'] = f.name

try:
self.driver = create_clidriver()
self.run_cmd(cmdline, expected_rc=255)
except ProfileNotFound as e:
self.assertIn(
'The config profile (user_profile) could not be found',
str(e)
)

@mock.patch('awscli.customizations.sessionmanager.check_call')
@mock.patch("awscli.customizations.sessionmanager.check_output")
def test_start_session_fails(self, mock_check_output, mock_check_call):
Expand Down
Loading

0 comments on commit 20a75d5

Please sign in to comment.