Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Description: Creates the SageMaker model, endpoint config and the endpoint to expose the FIFA 18 prediction
- Parameters:
- Domain:
- Description: Domain name
- Type: String
- Default: your_domain
- Function:
- Description: Function
- Type: String
- Default: your_function
- Region:
- Description: Region
- Type: String
- Default: your_region
- AccountID:
- Description: AWS Account ID
- Type: String
- Default: your_account_id
- InstanceType:
- Description: AWS Instance type for hosting the SageMaker model.
- Type: String
- Default: ml.m4.xlarge
- S3Bucket:
- Description: S3 Bucket Containing the custom model(s).
- Type: String
- Default: your_s3_bucket_name
- ModelNamePrefix:
- Description: Prefix for the model(s). This is useful in case we want to change the model naming convension
- Type: String
- Default: your_prefix
- ModelVersion:
- Description: Current version of the model
- Type: String
- Default: 1.0
- Environment:
- Type: String
- Default: prod
- Description: Define the environment
- Resources:
- Endpoint:
- Type: "AWS::SageMaker::Endpoint"
- Properties:
- EndpointName: !Sub ${Domain}--${Function}--predict-fifa-18-endpoint--${Environment}
- EndpointConfigName:
- !GetAtt EndpointConfig.EndpointConfigName
- Tags:
- - Key: Environment
- Value: !Sub ${Environment}
- - Key: Domain
- Value: !Sub ${Domain}
- - Key: Function
- Value: !Sub ${Function}
- - Key: Project
- Value: !Sub ${Domain}
- EndpointConfig:
- Type: "AWS::SageMaker::EndpointConfig"
- Properties:
- EndpointConfigName: !Sub ${Domain}--${Function}--predict-fifa-18-endpoint-config--${Environment}
- ProductionVariants:
- - InitialInstanceCount: 1
- InitialVariantWeight: 1.0
- InstanceType: !Sub ${InstanceType}
- ModelName: !GetAtt Model.ModelName
- VariantName: !GetAtt Model.ModelName
- Tags:
- - Key: Environment
- Value: !Sub ${Environment}
- - Key: Domain
- Value: !Sub ${Domain}
- - Key: Function
- Value: !Sub ${Function}
- - Key: Project
- Value: !Sub ${Domain}
- Model:
- Type: "AWS::SageMaker::Model"
- Properties:
- ModelName: !Sub ${Domain}--${Function}--predict-fifa-18-model--${Environment}
- PrimaryContainer:
- ModelDataUrl: !Sub "https://s3-${Region}.amazonaws.com/${S3Bucket}/models/${ModelNamePrefix}--v${ModelVersion}.hdf5.tar.gz"
- Image: !Sub "${AccountID}.dkr.ecr.${Region}.amazonaws.com/your_ecr_image_id:${ModelVersion}"
- ExecutionRoleArn: !GetAtt ExecutionRole.Arn
- Tags:
- - Key: Environment
- Value: !Sub ${Environment}
- - Key: Domain
- Value: !Sub ${Domain}
- - Key: Function
- Value: !Sub ${Function}
- - Key: Project
- Value: !Sub ${Domain}
- ExecutionRole:
- Type: "AWS::IAM::Role"
- Properties:
- RoleName: !Sub ${Domain}--${Function}--predict-fifa-18-role--${Environment}
- ManagedPolicyArns:
- - "arn:aws:iam::aws:policy/CloudWatchFullAccess"
- - "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
- AssumeRolePolicyDocument:
- Version: "2012-10-17"
- Statement:
- -
- Effect: "Allow"
- Principal:
- Service:
- - "sagemaker.amazonaws.com"
- Action:
- - "sts:AssumeRole"
- Path: "/"
- Policies:
- -
- PolicyName: !Sub ${Domain}--${Function}--predict-fifa-18-policy--${Environment}
- PolicyDocument:
- Version: "2012-10-17"
- Statement:
- - Action:
- - s3:ListBucket
- Effect: Allow
- Resource:
- - !Sub arn:aws:s3:::${S3Bucket}
- - Action:
- - s3:GetObject
- Effect: Allow
- Resource:
- - !Sub arn:aws:s3:::${S3Bucket}/*
- Outputs:
- EndpointId:
- Value: !Ref Endpoint
- EndpointName:
- Value: !GetAtt Endpoint.EndpointName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement