Skip to content

Commit 63cd2a1

Browse files
committed
add an attribute to AWSAccountClamp() for ReadOnly Roles
1 parent 49bdbd8 commit 63cd2a1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/workbench/core/artifacts/artifact.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ def upsert_workbench_meta(self, new_meta: dict):
236236
This functionality will work for FeatureSets, Models, and Endpoints
237237
but not for DataSources. The DataSource class overrides this method.
238238
"""
239+
240+
# Check for ReadOnly Role
241+
if self.aws_account_clamp.read_only_role:
242+
self.log.info("Cannot add metadata with a ReadOnly Role...")
243+
return
244+
239245
# Sanity check
240246
aws_arn = self.arn()
241247
if aws_arn is None:
@@ -444,10 +450,12 @@ def delete_metadata(self, key_to_delete: str):
444450

445451
if __name__ == "__main__":
446452
"""Exercise the Artifact Class"""
447-
from workbench.api.data_source import DataSource
448-
from workbench.api.feature_set import FeatureSet
453+
from workbench.api import DataSource, FeatureSet, Endpoint
454+
455+
# Grab an Endpoint (which is a subclass of Artifact)
456+
end = Endpoint("wine-classification")
449457

450-
# Create a DataSource (which is a subclass of Artifact)
458+
# Grab a DataSource (which is a subclass of Artifact)
451459
data_source = DataSource("test_data")
452460

453461
# Just some random tests

src/workbench/core/cloud_platform/aws/aws_account_clamp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def __init__(self):
5454

5555
# Check our Assume Role
5656
self.log.info("Checking Workbench Assumed Role...")
57-
self.aws_session.assumed_role_info()
57+
role_info = self.aws_session.assumed_role_info()
58+
59+
# Check if the Role is a 'ReadOnly' role
60+
self.read_only_role = "readonly" in role_info["AssumedRoleArn"].lower()
5861

5962
# Check our Workbench API Key and Load the License
6063
self.log.info("Checking Workbench API License...")

0 commit comments

Comments
 (0)