Skip to content

Commit 20afdce

Browse files
authored
Add support for ec2.assume_role command (#43)
* Add support for ec2.assume_role command * update changelog * lint * update changelog
1 parent 089d270 commit 20afdce

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 3.7.0 - 2025-03-18
4+
- Add support for `ec2.assume_role` to the list of `AvailableCommands`.
5+
36
## 3.6.0 - 2024-11-18
47
- Address Python 3.12+ compatibility issues.
58
- Address pydantic v2 compatibility issues.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "shrub.py"
3-
version = "3.6.0"
3+
version = "3.7.0"
44
description = "Library for creating evergreen configurations"
55
authors = ["DevProd Services & Integrations Team <[email protected]>"]
66
license = "Apache-2.0"

src/shrub/v3/evg_command.py

+26
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"attach.results",
1515
"attach.xunit_results",
1616
"downstream_expansions.set",
17+
"ec2.assume_role",
1718
"expansions.update",
1819
"expansions.write",
1920
"generate.tasks",
@@ -350,6 +351,31 @@ def downstream_expansions_set(
350351
)
351352

352353

354+
def ec2_assume_role(
355+
role_arn: str,
356+
policy: Optional[str] = None,
357+
duration_seconds: Optional[int] = None,
358+
command_type: Optional[EvgCommandType] = None,
359+
) -> BuiltInCommand:
360+
"""
361+
Command to call the aws assumeRole API and returns credentials as expansions.
362+
363+
:param role_arn: string ARN of the role you want to assume.
364+
:param policy: string in JSON format that you want to use as an inline session policy.
365+
:param duration_seconds: Int in seconds of how long the returned credentials will be valid.
366+
:return: ec2.assume_role command.
367+
"""
368+
return BuiltInCommand(
369+
command="ec2.assume_role",
370+
params={
371+
"role_arn": role_arn,
372+
"policy": policy,
373+
"duration_seconds": duration_seconds,
374+
},
375+
type=command_type,
376+
)
377+
378+
353379
def expansions_update(
354380
updates: Optional[List[KeyValueParam]] = None,
355381
file: Optional[str] = None,

0 commit comments

Comments
 (0)