We are using cloudformation to create jupyter notebook with tags we want. While when we execute Estimators, it will create a training job without any tags. We tried to copy tags from notebook instance to the job using python. However, due to "aws:cloudformation:stack-name" is reserved, it will fail to execute. Is there anyone know anyway to inherit tag from notebook instance?
The way we copy tags. It won't work unless we skip "aws:cloudformation:*" tags.
import json
with open('/opt/ml/metadata/resource-metadata.json', 'r') as logs:
meta_data = json.load(logs)
org_tags = boto3.client("sagemaker").list_tags(ResourceArn = meta_data['ResourceArn'])['Tags']
tags = {}
for org_tag in org_tags:
tags[org_tag['Key']] = org_tag['Value']
tabular_estimator = Estimator(
role=aws_role,
image_uri=train_image_uri,
source_dir=train_source_uri,
model_uri=train_model_uri,
entry_point="transfer_learning.py",
instance_count=1,
instance_type=training_instance_type,
max_run=360000,
hyperparameters=hyperparameters,
output_path=s3_output_location,
tags = tags
)
# Launch a SageMaker Training job by passing the S3 path of the training data
predictor = estimator.fit(
{
"training": training_dataset_s3_path,
"validation": validation_dataset_s3_path,
}, logs=False, job_name=training_job_name
)
Also we we check the cloudtrail the username is also "sagemaker". Is there anyway to make the username link back to who execute the notebook?

Thank you