in sagemaker_studio_image_build/codebuild.py [0:0]
def __enter__(self):
client = self.session.client("codebuild")
region = self.session.region_name
caller_identity = self.session.client("sts").get_caller_identity()
account = caller_identity["Account"]
partition = caller_identity["Arn"].split(":")[1]
args = {
"name": self.project_name,
"description": f"Build the image for {self.repo_name} in SageMaker Studio",
"source": {"type": "S3", "location": self.s3_location},
"artifacts": {"type": "NO_ARTIFACTS"},
"environment": {
"type": "LINUX_CONTAINER",
"image": "aws/codebuild/standard:4.0",
"computeType": self.compute_type,
"environmentVariables": [
{"name": "AWS_DEFAULT_REGION", "value": region},
{"name": "AWS_ACCOUNT_ID", "value": account},
{"name": "IMAGE_REPO_NAME", "value": self.repo_name},
{"name": "IMAGE_TAG", "value": self.tag},
],
"privilegedMode": True,
},
"serviceRole": f"arn:{partition}:iam::{account}:role/{self.role}",
}
if self.vpc_config is not None:
args["vpcConfig"] = self.vpc_config
client.create_project(**args)
return self