# Problem Statement
We have a need to create Instance Profiles via the Databricks REST API, but the endpoint returns an "INVALID_PARAMETER_VALUE" error with "Syntactically invalid AWS instance profile ARN" message even when provided an appropriate ARN as input.
# What's been done
- Creating Role and Instance Profile on Databricks AWS account via AWS CLI
- Calling /instance-profiles/add to register Instance Profile in Databricks
# Code
def create_instance_profile(instance_profile_arn, skip_validation = False):
api_command = '/instance-profiles/add'
api_version = f'/api/2.0'
url = f"https://{DATABRICKS_HOST}{api_version}{api_command}"
params = {
"instance_profile_arn" : instance_profile_arn,
"skip_validation" : skip_validation,
"is_meta_instance_profile" : False
}
header = {
"accept": "application/scim+json",
"Authorization": f"Bearer {DATABRICKS_TOKEN}"
}
response = requests.post(url, params = params, headers=header)
print(json.dumps(json.loads(response.text), indent = 2))
arn = "arn:aws:iam::<account_id>:instance-profile/my-instance-profile-name"
create_instance_profile(arn)