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

change: Update contents of key pipeline notebooks based on latest SDK update #3499

Merged
merged 2 commits into from
Jul 14, 2022
Merged
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions sagemaker-pipelines/tabular/lambda-step/iam_helper.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import boto3
import json

iam = boto3.client('iam')
iam = boto3.client("iam")


def create_lambda_role(role_name):
try:
response = iam.create_role(
RoleName = role_name,
AssumeRolePolicyDocument = json.dumps({
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}),
Description='Role for Lambda to call SageMaker functions'
RoleName=role_name,
AssumeRolePolicyDocument=json.dumps(
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": "sts:AssumeRole",
}
],
}
),
Description="Role for Lambda to call SageMaker functions",
)

role_arn = response['Role']['Arn']
role_arn = response["Role"]["Arn"]

response = iam.attach_role_policy(
RoleName=role_name,
PolicyArn='arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
PolicyArn="arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
)

response = iam.attach_role_policy(
PolicyArn='arn:aws:iam::aws:policy/AmazonSageMakerFullAccess',
RoleName=role_name
PolicyArn="arn:aws:iam::aws:policy/AmazonSageMakerFullAccess", RoleName=role_name
)

return role_arn

except iam.exceptions.EntityAlreadyExistsException:
print(f'Using ARN from existing role: {role_name}')
print(f"Using ARN from existing role: {role_name}")
response = iam.get_role(RoleName=role_name)
return response['Role']['Arn']
return response["Role"]["Arn"]
Loading