xiaohongshu
xiaohongshu
aws-prescriptive-guidance
AWS Prescriptive Guidance for best practices and architectural patterns. Use for AWS architecture recommendations, SageMaker AI endpoints guidance, deployment patterns, and AWS solution architectures.
Full skill instructions
Comprehensive AWS architectural patterns, ML deployment strategies, and cloud design best practices from official AWS documentation.
This skill should be triggered when:
Specific triggers:
Deploy preprocessing and ML model in a single endpoint:
import sagemaker
from sagemaker import get_execution_role
# Initialize SageMaker session
sagemaker_session = sagemaker.Session()
role = get_execution_role()
bucket = sagemaker_session.default_bucket()
# Upload training data
train_input = sagemaker_session.upload_data(
path="data/training.csv",
bucket=bucket,
key_prefix="myproject/train"
)
Build a preprocessing stage for your inference pipeline:
from sagemaker.sklearn.estimator import SKLearn
sklearn_preprocessor = SKLearn(
entry_point="preprocessing.py",
role=role,
framework_version="0.23-1",
instance_type="ml.c4.xlarge",
sagemaker_session=sagemaker_session
)
sklearn_preprocessor.fit({"train": train_input})
Create and train a regression model:
from sagemaker.image_uris import retrieve
ll_image = retrieve("linear-learner", boto3.Session().region_name)
ll_estimator = sagemaker.estimator.Estimator(
ll_image,
role,
instance_count=1,
instance_type="ml.m4.2xlarge",
output_path=f"s3://{bucket}/model-output"
)
ll_estimator.set_hyperparameters(
feature_dim=10,
predictor_type="regressor",
mini_batch_size=32
)
ll_estimator.fit({"train": preprocessed_data})
Combine preprocessing and inference in single endpoint:
from sagemaker.pipeline import PipelineModel
from time import gmtime, strftime
# Create models from trained estimators
preprocessing_model = sklearn_preprocessor.create_model()
inference_model = ll_estimator.create_model()
# Create pipeline
timestamp = strftime("%Y-%m-%d-%H-%M-%S", gmtime())
pipeline = PipelineModel(
name=f"pipeline-{timestamp}",
role=role,
models=[preprocessing_model, inference_model]
)
# Deploy to endpoint
pipeline.deploy(
initial_instance_count=1,
instance_type="ml.c4.xlarge",
endpoint_name=f"pipeline-endpoint-{timestamp}"
)
Send data to your deployed pipeline:
from sagemaker.predictor import Predictor
from sagemaker.serializers import CSVSerializer
predictor = Predictor(
endpoint_name="pipeline-endpoint-2024-01-15",
sagemaker_session=sagemaker_session,
serializer=CSVSerializer()
)
# Raw data input (preprocessing happens automatically)
payload = "0.44, 0.365, 0.125, 0.516, 0.2155, 0.114"
prediction = predictor.predict(payload)
print(f"Prediction: {prediction}")
Test preprocessing before full pipeline deployment:
# Create transformer from preprocessor
transformer = sklearn_preprocessor.transformer(
instance_count=1,
instance_type="ml.m5.xlarge",
assemble_with="Line",
accept="text/csv"
)
# Transform training data
transformer.transform(train_input, content_type="text/csv")
transformer.wait()
# Get preprocessed output location
preprocessed_data = transformer.output_path
Implement resilient service calls with circuit breaker:
from enum import Enum
import time
class CircuitState(Enum):
CLOSED = "closed"
OPEN = "open"
HALF_OPEN = "half_open"
class CircuitBreaker:
def __init__(self, failure_threshold=5, timeout=60):
self.state = CircuitState.CLOSED
self.failures = 0
self.failure_threshold = failure_threshold
self.timeout = timeout
self.last_failure_time = None
def call(self, func, *args, **kwargs):
if self.state == CircuitState.OPEN:
if time.time() - self.last_failure_time > self.timeout:
self.state = CircuitState.HALF_OPEN
else:
raise Exception("Circuit breaker is OPEN")
try:
result = func(*args, **kwargs)
self.on_success()
return result
except Exception as e:
self.on_failure()
raise e
def on_success(self):
self.failures = 0
self.state = CircuitState.CLOSED
def on_failure(self):
self.failures += 1
self.last_failure_time = time.time()
if self.failures >= self.failure_threshold:
self.state = CircuitState.OPEN
Implement resilient API calls:
import time
import random
def retry_with_backoff(func, max_retries=5, base_delay=1, max_delay=60):
"""
Retry function with exponential backoff and jitter
"""
for attempt in range(max_retries):
try:
return func()
except Exception as e:
if attempt == max_retries - 1:
raise e
# Calculate exponential backoff with jitter
delay = min(base_delay * (2 ** attempt), max_delay)
jitter = random.uniform(0, delay * 0.1)
sleep_time = delay + jitter
print(f"Attempt {attempt + 1} failed. Retrying in {sleep_time:.2f}s")
time.sleep(sleep_time)
# Usage
result = retry_with_backoff(lambda: api_call())
Decouple services with pub-sub messaging:
import boto3
# Create SNS client
sns = boto3.client('sns')
sqs = boto3.client('sqs')
# Create topic
topic_response = sns.create_topic(Name='order-events')
topic_arn = topic_response['TopicArn']
# Create queue and subscribe to topic
queue_response = sqs.create_queue(QueueName='order-processing')
queue_url = queue_response['QueueUrl']
queue_arn = sqs.get_queue_attributes(
QueueUrl=queue_url,
AttributeNames=['QueueArn']
)['Attributes']['QueueArn']
# Subscribe queue to topic
sns.subscribe(
TopicArn=topic_arn,
Protocol='sqs',
Endpoint=queue_arn
)
# Publish message
sns.publish(
TopicArn=topic_arn,
Message='{"order_id": "12345", "status": "created"}',
Subject='OrderCreated'
)
Serverless API with request routing:
import json
def lambda_handler(event, context):
"""
Lambda function for API Gateway integration
"""
# Extract request details
http_method = event.get('httpMethod')
path = event.get('path')
body = json.loads(event.get('body', '{}'))
# Route based on method and path
if http_method == 'GET' and path == '/items':
return {
'statusCode': 200,
'headers': {'Content-Type': 'application/json'},
'body': json.dumps({'items': ['item1', 'item2']})
}
elif http_method == 'POST' and path == '/items':
# Process new item
item_id = body.get('id')
return {
'statusCode': 201,
'headers': {'Content-Type': 'application/json'},
'body': json.dumps({'id': item_id, 'status': 'created'})
}
return {
'statusCode': 404,
'body': json.dumps({'error': 'Not found'})
}
AWS Prescriptive Guidance covers 13 primary architectural patterns for modern cloud applications:
Inference Pipelines:
MLOps Workflows:
Architecture Benefits:
Modern applications emphasize:
Integration Patterns:
Resilience Patterns:
Data Patterns:
Migration Patterns:
Official AWS Prescriptive Guidance best practices for cloud architecture, covering:
When to use: Start here for general AWS architecture guidance and foundational principles.
Comprehensive catalog of AWS implementation patterns, including:
When to use: Reference when implementing specific solutions or looking for proven architectural approaches.
Start with:
best_practices.md for AWS foundational conceptsRecommended learning path:
Focus on:
Navigation tips:
patterns.md for comprehensive implementation guidesDeep dive into:
Best practices:
# Install required Python packages
pip install boto3 sagemaker scikit-learn pandas numpy
# Configure AWS credentials
aws configure
This skill is based on AWS Prescriptive Guidance documentation. AWS regularly updates patterns and best practices, so:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience