{"id":18485913,"url":"https://github.com/biomapas/b.cfnsagemakerendpoint","last_synced_at":"2026-04-30T09:32:53.003Z","repository":{"id":45321587,"uuid":"438224239","full_name":"Biomapas/B.CfnSagemakerEndpoint","owner":"Biomapas","description":"AWS CDK resource that handles the deployment and update of SageMaker models' endpoint any time the code changes in your S3 bucket.","archived":false,"fork":false,"pushed_at":"2021-12-21T14:33:09.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-25T14:29:41.198Z","etag":null,"topics":["aws","aws-cdk","aws-cdk-python","aws-cloudformation","sagemaker","sagemaker-deployment","sagemaker-endpoint"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Biomapas.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-14T11:17:49.000Z","updated_at":"2021-12-21T14:33:12.000Z","dependencies_parsed_at":"2022-09-01T20:25:06.705Z","dependency_job_id":null,"html_url":"https://github.com/Biomapas/B.CfnSagemakerEndpoint","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnSagemakerEndpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnSagemakerEndpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnSagemakerEndpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnSagemakerEndpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Biomapas","download_url":"https://codeload.github.com/Biomapas/B.CfnSagemakerEndpoint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239201656,"owners_count":19599079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cdk","aws-cdk-python","aws-cloudformation","sagemaker","sagemaker-deployment","sagemaker-endpoint"],"created_at":"2024-11-06T12:47:06.972Z","updated_at":"2025-10-31T14:30:30.351Z","avatar_url":"https://github.com/Biomapas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Pipeline](https://github.com/Biomapas/B.CfnSagemakerEndpoint/workflows/Pipeline/badge.svg?branch=master)\n\n# B.CfnSagemakerEndpoint\n\n**b-cfn-sagemaker-endpoint** - AWS CloudFormation resource that handles the deployment and update of \nSageMaker models endpoint.\n\n### Description\n\nThis resource handles the deployment and update of SageMaker models endpoint. It is designed to \nenable automatic update of SageMaker's models endpoint in the event of modifying the source model data. \nThis is achieved by utilizing S3's' event notifications. On updating the target S3 bucket objects, \nan event is emitted that is handled by a lambda function which updates the deployed SageMaker endpoint.\n\n#### Design\n\nThis resource implements architecture showed in the following UML diagram:\n\n![Architecture diagram](images/architecture.svg)\n\nEndpoint update is done via `boto3`'s function `update_endpoint()` that requires a new \nconfiguration to be provided. Instead of creating a new instance of it each time, two identical \nconfigurations (A \u0026 B) with different names are created only once, during the deployment. Each \n`update_endpoint()` call effectively swaps them together, allowing the endpoint to be refreshed with new \nup-to-date source model(-s) data. This can be seen in the UML activity diagram below:\n\n![Activity diagram](images/activity-diagram.svg)\n\n### Remarks\n\n[Biomapas](https://biomapas.com) aims to modernise life-science\nindustry by sharing its IT knowledge with other companies and\nthe community.\n\n### Related technology\n\n- Python \u003e= 3.8\n- Amazon Web Services (AWS)\n- Amazon SageMaker\n\n### Assumptions\n\nThe project assumes that the person working with it have basic knowledge in python\nprogramming.\n\n### Useful sources\n\nSageMaker documentation:\n- [Developer guide](https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html)\n- [AWS SDK for Python (Boto 3)](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html?icmpid=docs_sagemaker_lp)\n\nSee code documentation for any additional sources and references.\n\n### Install\n\nUse the package manager pip to install this package. This project is not in the PyPi\nrepository yet. Install directly from source or PyPI.\n\n```bash\npip install .\n```\n\nOr\n\n```bash\npip install b-cfn-sagemaker-endpoint\n```\n\n### Usage \u0026 Examples\n\nThis resource handles ``aws-cdk.aws-sagemaker`` library's resources: ``CnfModel``, ``CnfEndpointConfig`` \u0026 \n``CnfEndpoint`` deployment. The user is required only to provide configurations for each of these items via \ntheir properties, i.e.: ``CnfModelProps`` -\u003e ``CnfModel``, that on themselves do not create any resources.\n\nTo deploy a SageMaker model(-s) endpoint the following steps have to be taken:\n\n1. Configure SageMaker model properties as a ``ModelProps`` class object:\n    ```python\n    example_model_props = ModelProps(\n        props=CfnModelProps(...),\n        custom_id=..., # (optional) If not provided, it is generated automatically.\n    )\n    ```\n   **Note:** `CfnModelProps` require an execution role ARN. This role must have ``sagemaker.amazonaws.com`` set as the \n   trusted entity that can assume it. In usual cases the following permissions are required:\n   ```json\n   {\n       \"Version\": \"2012-10-17\",\n       \"Statement\": [\n           {\n               \"Action\": [\n                   \"cloudwatch:PutMetricData\",\n                   \"ecr:GetAuthorizationToken\",\n                   \"ecr:BatchCheckLayerAvailability\",\n                   \"ecr:GetDownloadUrlForLayer\",\n                   \"ecr:BatchGetImage\",\n                   \"logs:CreateLogStream\",\n                   \"logs:PutLogEvents\",\n                   \"logs:CreateLogGroup\",\n                   \"logs:DescribeLogStreams\"\n               ],\n               \"Resource\": \"*\",\n               \"Effect\": \"Allow\"\n           },\n           {\n               \"Action\": [\n                   \"s3:PutObject\",\n                   \"s3:ListBucket\",\n                   \"s3:GetObject\",\n                   \"s3:DeleteObject\"\n               ],\n               \"Resource\": \"*\",\n               \"Effect\": \"Allow\"\n           }\n       ]\n   }\n   ```\n\n2. Setup SageMaker endpoint configuration properties as ``CfnEnpointConfigProps``:\n    ```python\n    example_endpoint_config_props = CfnEndpointConfigProps(...)\n    ```\n   \n3. Configure SageMaker endpoint properties as ``CfnEnpointProps``:\n    ```python\n    example_endpoint_props = CfnEndpointProps(...)\n    ```\n   \n4. Finally, setup ``B.CfnSagemakerEndpoint``'s ``SagemakerEndpoint`` resource using previously defined \n   properties:\n    ```python\n    SagemakerEndpoint(\n        scope=...,\n        id='your-scoped-cdk-resource-id',\n        endpoint_props=example_endpoint_props,\n        endpoint_config_props=example_endpoint_config_props,\n        models_props=[\n            example_model_props\n        ],\n        models_bucket=Bucket(...),\n        # (Optional) If no explicit bucket events are provided, `EventType.OBJECT_CREATED` \n        # events are emitted for all bucket objects.\n        bucket_events=[\n            BucketEvent(EventType.OBJECT_CREATED, [\n                NotificationKeyFilter(\n                    prefix=...,\n                    # (Optional) Setting suffix, specifies on which files changes, based on \n                    # file type, should endpoint be updated. This is useful if updates are \n                    # required only for SageMaker model objects, i.e.: \"model.tar.gz\". \n                    # By default, if no bucket events are explicitly provided suffix is set \n                    # to \".tar.gz\".\n                    suffix='.tar.gz'\n                )\n            ])\n        ],\n        # (Optional) Set this value to the max time (in seconds) for how long it will take \n        # to upload updated contents to the S3 bucket. By default it is set to 60 seconds.\n        wait_time=...\n    )\n    ```\n    \nOnce, ``SagemakerEndpoint`` is deployed, any changes in the source models bucket specified by \n``bucket_events``, starts endpoint update/refresh. During this time, it's status becomes \"Updating\" \n\u0026 no further update calls are handled.\n\n### Known limits\n\nChanging settings of ``CfnModel`` or ``CfnEndpointConfig`` resources, does not update the ``CfnEndpoint`` \nresource itself. To achieve this functionality, likely, a low-level CustomResource implementation would be \nrequired.\n\n### Testing\n\nFor now, a single test is implemented to make sure that the SageMaker endpoint is automatically \nupdated with the latest model data found in the source S3 bucket.\n\n### Contribution\n\nFound a bug? Want to add or suggest a new feature? Contributions of any kind are gladly\nwelcome. Contact your direct supervisor, create a pull-request or an issue in Jira platform.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiomapas%2Fb.cfnsagemakerendpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiomapas%2Fb.cfnsagemakerendpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiomapas%2Fb.cfnsagemakerendpoint/lists"}