This guide establishes the guardrails required to interact with the Threat Classifier SageMaker environment using the AWS CLI. It focuses on secure-by-default configuration, FinOps visibility, and day-2 operations readiness.
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.27.50.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
aws --version # verify 2.27.50Why this version? 2.27.50 aligns with current SageMaker feature parity and prevents drift across local, CI, and CDK pipelines.
- Generate IAM access keys for a least-privilege role (ideally assume-role via SSO). Start with a profile name like
sagemaker-dev. - Store credentials using the CLI:
aws configure --profile sagemaker-dev
- Set the default region (e.g.,
us-west-2) and JSON output format. - Enable MFA or SSO in
~/.aws/config:[profile sagemaker-dev] region = us-west-2 output = json mfa_serial = arn:aws:iam::123456789012:mfa/your-user role_arn = arn:aws:iam::123456789012:role/ThreatClassifierDeployment source_profile = default
GovCloud note: When targeting GovCloud, configure
region = us-gov-west-1(or appropriate) and ensure the profile references a GovCloud account with mirrored IAM roles.
Set default tags at the CLI level to enforce FinOps hygiene across CDK and manual commands:
[default]
cli_timestamp_format = iso8601
[profile sagemaker-dev]
region = us-west-2
output = json
tags = App=ThreatClassifier,Env=dev,CostCenter=SecOps,Owner=ThreatClassifierTeamThese tags propagate automatically when resources are created through the CLI or CDK stack, enabling accurate cost allocation dashboards.
The project expects the following variables (see .env.example):
AWS_PROFILE- matches the named profile, e.g.,sagemaker-dev.AWS_REGION- deployment region (us-west-2by default).DATA_CAPTURE_S3_PREFIX- S3 URI used for Model Monitor data capture.MODEL_MONITOR_ENABLED- toggle (true/false) controlling capture & monitoring jobs.COST_CENTER_TAG- matches FinOps tags for auditing.
Load them before running CDK or training:
export $(grep -v '^#' .env | xargs)aws --versionreturns 2.27.50.aws sts get-caller-identity --profile sagemaker-devsucceeds with the expected account ID.aws configure list-profilesincludes the dedicated SageMaker profiles.- Cost allocation tags are visible under Billing > Cost Allocation Tags in the console.
- MFA challenge triggers when calling privileged APIs.
| Symptom | Resolution |
|---|---|
CLI reports Unknown options: --profile |
Upgrade to v2.27.50, older v1 commands differ. |
AccessDenied from SageMaker APIs |
Verify IAM policy grants CreateModel, CreateEndpoint, PassRole to the SageMaker execution role. |
| MFA required but not prompted | Confirm mfa_serial is set for the profile and that your terminal cache supports prompting. |
| Cost tags missing | Re-run aws configure set profile.sagemaker-dev.tags "App=...,Env=...,CostCenter=...,Owner=...". |
With the CLI standardized, you can proceed to CDK deployments and automated pipelines with consistent governance.