Skip to content
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

update iam-role to iam-role-mapping #4023

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions paasta_tools/contrib/service_shard_update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import json
import logging
import sys

Expand Down Expand Up @@ -165,11 +166,11 @@ def parse_args():
dest="autotune_max_disk",
)
parser.add_argument(
"--iam-role",
help="IAM role to use for the shard",
"--iam-role-mapping",
help="JSON string of deploy_prefix to IAM role mapping to use for the shard",
required=False,
type=str,
dest="iam_role",
dest="iam_role_mapping",
)
Comment on lines 168 to 174
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll probably want to have both args exist temporarily - otherwise, there'll be a brief period of time where this is broken since either --iam-role or --iam-role-mapping won't exist in the deployed paasta package

return parser.parse_args()

Expand Down Expand Up @@ -208,6 +209,9 @@ def main(args):
f"{prefix}.{args.shard_name}" for prefix in DEPLOY_MAPPINGS.keys()
}
pipeline_steps = {step["step"] for step in deploy_file["pipeline"]}
iam_role_mapping = {}
if args.iam_role_mapping:
iam_role_mapping = json.loads(args.iam_role_mapping)

if not shard_deploy_groups.issubset(pipeline_steps):
changes_made = True
Expand Down Expand Up @@ -271,8 +275,8 @@ def main(args):
metrics_provider_config
)

if args.iam_role is not None:
instance_config["iam_role"] = args.iam_role
if deploy_prefix in iam_role_mapping:
instance_config["iam_role"] = iam_role_mapping[deploy_prefix]
if args.cpus is not None:
instance_config["cpus"] = args.cpus
if args.mem is not None:
Expand Down
Loading