From Dev to Production: Deployment and Administration
From Dev to Production: Deployment and Administration
Section titled “From Dev to Production: Deployment and Administration”Taking your AI-powered solutions from your local machine to a scalable, secure production environment is a critical step. This chapter covers the essentials of deploying, managing, and monitoring Claude Code in a professional setting.
Deployment Strategies on Cloud Platforms
Section titled “Deployment Strategies on Cloud Platforms”Running Claude Code through dedicated cloud services like Amazon Bedrock and Google Vertex AI offers significant advantages in terms of scalability, security, and manageability.
Amazon Bedrock
Section titled “Amazon Bedrock”Amazon Bedrock provides a fully managed service to access foundation models. To use Claude Code with Bedrock, you first need to request model access in the AWS console. Then, configure your environment to use AWS credentials instead of a direct Anthropic API key.
- Authentication: Claude Code will automatically use the standard AWS credential chain (environment variables,
.aws/credentialsfile, IAM roles). The/loginand/logoutcommands are disabled as auth is managed via AWS. - Configuration: You must set the
AWS_REGIONenvironment variable. You can also specify anAWS_PROFILEif you have multiple configurations. - Token Management: Bedrock has specific throttling logic. It’s recommended to set
CLAUDE_CODE_MAX_OUTPUT_TOKENSto at least4096in your configuration to avoid premature task failures.
Google Vertex AI
Section titled “Google Vertex AI”Similarly, Google’s Vertex AI provides access to Claude models within the Google Cloud ecosystem. Deployment involves authenticating your environment with Google Cloud credentials and configuring Claude Code to route its requests through the Vertex AI API.
- Authentication: Use the
gcloud auth application-default logincommand to authenticate your environment. Claude Code will then pick up these credentials automatically. - Project Configuration: You’ll need to set your Google Cloud Project ID and the appropriate location (region) in your environment for Claude Code to connect successfully.
Navigating Corporate Proxies and LLM Gateways
Section titled “Navigating Corporate Proxies and LLM Gateways”In many corporate environments, direct internet access is restricted. To use Claude Code, you’ll need to configure it to work with your company’s network infrastructure.
- Corporate Proxies: If your network routes traffic through an HTTP/S proxy, you must set the standard
HTTP_PROXYandHTTPS_PROXYenvironment variables. Claude Code will respect these settings for all its network requests. - LLM Gateways: An LLM Gateway is a specialized proxy that sits between your application and the AI model provider. It provides centralized control over security, cost management, and observability. To use Claude Code with a gateway, you typically configure the API endpoint in your settings file to point to the gateway’s URL instead of the default Anthropic API endpoint.
Critical Administrative Topics
Section titled “Critical Administrative Topics”Identity and Access Management (IAM)
Section titled “Identity and Access Management (IAM)”When deploying on AWS or Google Cloud, use their native IAM services to enforce the principle of least privilege. Create dedicated IAM roles or service accounts for your Claude Code applications with policies that grant only the necessary permissions (e.g., bedrock:InvokeModel) to interact with the Claude models. Avoid using root user credentials or overly permissive policies in production.
Security Best Practices
Section titled “Security Best Practices”Security is paramount. Follow these guidelines to protect your applications:
- Key Management: Never hardcode API keys or credentials in your source code. Use a secrets management service like AWS Secrets Manager, Google Secret Manager, or GitHub Secrets.
- Sandbox Execution: Claude Code operates within the boundaries of the project folder you run it in. Be cautious when granting it access to sensitive directories. Always review code or commands that modify the file system.
- Input Validation: Sanitize and validate any user-provided input that is passed into a prompt to mitigate the risk of prompt injection attacks.
Data Usage, Monitoring, and Cost Analysis
Section titled “Data Usage, Monitoring, and Cost Analysis”Understanding your usage is key to managing costs and performance.
- Data Usage: Be aware of Anthropic’s data usage policies. Data sent to the API is not used to train their foundational models unless you opt-in to submit it for that purpose.
- Monitoring: Use cloud-native monitoring tools (like Amazon CloudWatch or Google Cloud Monitoring) to track API latency, error rates, and token counts. Third-party services like Datadog also offer integrations for detailed cost and usage breakdowns.
- Cost Analysis: Costs are primarily driven by the number of input and output tokens processed. Use the most cost-effective model that meets your needs (e.g., use Sonnet for simpler tasks and Opus for complex reasoning). Implement caching strategies for repeated queries and set usage alerts to avoid unexpected bills.