AWS Builder Center
Building Secure Blockchain Applications on AWS: Amazon Managed Blockchain, Ethereum, and Serverless Architecture

Building Secure Blockchain Applications on AWS: Amazon Managed Blockchain, Ethereum, and Serverless Architecture

Learn how to build secure blockchain applications on AWS using Amazon Managed Blockchain Access, AWS Lambda, API Gateway, DynamoDB, and KMS. Explore Ethereum JSON-RPC integration, serverless architecture, transaction monitoring, IAM security, and production best practices for scalable Web3 applications.

Security engineer
  • Building Secure Blockchain Applications on AWS: Amazon Managed Blockchain, Ethereum, and Serverless Architecture

Introduction

Blockchain technology has evolved beyond cryptocurrency trading. Today, organizations use distributed ledgers and smart contracts to develop financial applications, tokenization platforms, supply-chain systems, and decentralized services.
However, building blockchain applications introduces challenges beyond smart-contract development.
Developers must consider infrastructure availability, API security, transaction integrity, private-key management, observability, scalability, and operational costs.
Amazon Web Services (AWS) provides managed and serverless services that can help address these challenges.
In this article, we will explore how to design a blockchain application using Amazon Managed Blockchain (AMB) Access, Amazon API Gateway, AWS Lambda, Amazon DynamoDB, Amazon CloudWatch, and AWS Key Management Service (KMS).
We will also demonstrate how to interact with Ethereum-compatible JSON-RPC interfaces and discuss the security controls required for production Web3 environments.



1. Understanding Blockchain Infrastructure on AWS

A blockchain application typically consists of two distinct environments:
  1. On-chain infrastructure: Smart contracts, blockchain transactions, validators, and distributed consensus.
  1. Off-chain infrastructure: APIs, databases, authentication services, business logic, analytics, and monitoring.
Although blockchain networks provide distributed execution and verification, most real-world applications still depend on conventional infrastructure.
For example, a decentralized finance application may execute transactions through Ethereum smart contracts while using AWS to manage user authentication, application APIs, notifications, and transaction analytics.
AWS can support the off-chain application and provide managed access to blockchain networks.
However, hosting application components on AWS does not automatically make those components decentralized.

2. What Is Amazon Managed Blockchain?

Amazon Managed Blockchain is a collection of managed blockchain capabilities.
For public blockchain applications, Amazon Managed Blockchain Access provides managed connectivity to supported blockchain networks.
Depending on the supported network and service offering, applications can access blockchain data and interact with network interfaces without operating all underlying node infrastructure themselves.
Relevant capabilities include:
  • Managed blockchain network connectivity.
  • Ethereum-compatible JSON-RPC access where supported.
  • Integration with AWS applications.
  • Blockchain data access.
  • Support for event-driven architectures.
  • Reduced operational overhead compared with managing dedicated nodes.
AWS also offers related blockchain data capabilities, including Amazon Managed Blockchain Query for supported blockchain datasets.
Availability, supported networks, APIs, pricing, and regional coverage should always be checked against current AWS documentation.

Managed Access vs. Self-Hosted Nodes

Characteristic
Managed Blockchain Access
Self-Hosted Blockchain Node
Infrastructure operations
Primarily managed by AWS
Managed by the organization
Node maintenance
Reduced operational responsibility
Requires ongoing maintenance
Custom node configuration
Limited by service capabilities
Greater control
Integration
AWS-compatible service interfaces
Custom infrastructure integration
Operational complexity
Generally lower
Generally higher
Costs
Service-specific usage charges
Compute, storage, network, and operations
Managed access can be attractive when the primary goal is to build blockchain-enabled applications rather than operate blockchain infrastructure.

3. Reference Architecture: Serverless Blockchain Application

A practical architecture can combine managed blockchain access with AWS serverless services.

Architecture Overview

End Users
|
v
Amazon API Gateway
|
v
AWS Lambda
|
+---------+---------+
| |
v v
Amazon DynamoDB AWS Secrets Manager
| |
+---------+---------+
|
v
Amazon Managed Blockchain
Access
|
v
Ethereum Network
|
v
Smart Contracts

Monitoring and Security
-----------------------
Amazon CloudWatch
AWS CloudTrail
AWS IAM
Amazon GuardDuty
AWS KMS

Component Responsibilities

Amazon API Gateway
Exposes controlled HTTP endpoints for application clients.
AWS Lambda
Executes backend business logic, validates requests, and interacts with blockchain APIs.
Amazon DynamoDB
Stores application-specific metadata, transaction tracking information, and processing state.
AWS Secrets Manager
Protects supported application secrets and configuration values that should not be embedded in source code.
Amazon Managed Blockchain Access
Provides managed connectivity to supported blockchain networks.
Amazon CloudWatch
Collects application logs, metrics, and alarms.
AWS IAM
Controls permissions for supported AWS service operations.
AWS KMS
Provides cryptographic key management and signing capabilities for compatible use cases.



4. Connecting to Ethereum Using JSON-RPC

Ethereum applications commonly communicate with blockchain nodes using JSON-RPC.
JSON-RPC allows clients to request blockchain information, including:
  • Current block number.
  • Transaction details.
  • Account balances.
  • Transaction receipts.
  • Smart-contract execution results.
  • Network information.
For example, the Ethereum method  eth_blockNumber  returns the latest block number known to the endpoint.

Example JSON-RPC Request

{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
A successful response contains a hexadecimal block number.
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x123456"
}
The example result is illustrative.

Authentication Considerations

Amazon Managed Blockchain Access endpoints may require AWS Signature Version 4 authentication or other service-specific authentication mechanisms, depending on the API and network.
A generic unauthenticated JSON-RPC HTTP request should not be assumed to work against an AWS-managed endpoint.
For production implementations, use the authentication approach documented for the specific AMB service and endpoint.

5. Building an AWS Lambda Blockchain Reader

We can create a Python Lambda function that retrieves the latest Ethereum block number.
The following example assumes an Ethereum JSON-RPC endpoint that is accessible to the function and supports the configured authentication method.
For Amazon Managed Blockchain Access, additional request signing may be required.

Python Example

import json
import os
import urllib.request

RPC_ENDPOINT = os.environ["RPC_ENDPOINT"]

def lambda_handler(event, context):
payload = {
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}

request = urllib.request.Request(
RPC_ENDPOINT,
data=json.dumps(payload).encode("utf-8"),
headers={
"Content-Type": "application/json"
},
method="POST"
)

with urllib.request.urlopen(
request,
timeout=10
) as response:
result = json.loads(response.read())

if "error" in result:
raise RuntimeError(
f"Blockchain RPC error: {result['error']}"
)

block_number = int(result["result"], 16)

return {
"statusCode": 200,
"body": json.dumps({
"latest_block": block_number
})
}

Environment Configuration

Configure the Lambda environment variable:
RPC_ENDPOINT=https://your-authorized-rpc-endpoint
Use a properly authenticated endpoint and do not expose access credentials in application logs or public source repositories.
The example demonstrates basic JSON-RPC interaction. A production implementation should include service-specific authentication, retries, error classification, and endpoint access controls.

6. Storing Blockchain Transaction Metadata in DynamoDB

Blockchain transactions are stored on-chain, but applications frequently require additional off-chain metadata.
Examples include:
  • Application user identifiers.
  • Transaction submission timestamps.
  • Processing status.
  • Business workflow identifiers.
  • Notification state.
  • Transaction confirmation tracking.
Amazon DynamoDB can support these workloads.

Example Transaction Record

{
"transaction_hash": "0xexamplehash",
"network": "ethereum",
"status": "pending",
"created_at": "2026-11-04T12:00:00Z",
"confirmations": 0
}
This is an illustrative application record, not a valid Ethereum transaction hash.

Example DynamoDB Write

import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("BlockchainTransactions")

def save_transaction(tx_hash, network):
table.put_item(
Item={
"transaction_hash": tx_hash,
"network": network,
"status": "pending"
}
)
For production use, define suitable primary keys, validation rules, retention policies, and access controls.
Do not store private keys or sensitive signing material in ordinary application records.

7. Securing Blockchain Applications with AWS IAM

Identity and Access Management is essential for protecting the AWS infrastructure supporting blockchain applications.
A compromised cloud identity could allow an attacker to:
  • Modify Lambda functions.
  • Read sensitive application configuration.
  • Change API Gateway settings.
  • Access application data.
  • Alter monitoring or logging configurations.
  • Invoke privileged cryptographic operations where permitted.

Recommended IAM Controls

  • Apply least-privilege permissions.
  • Use IAM roles instead of long-lived access keys.
  • Separate development and production environments.
  • Restrict privileged administrative actions.
  • Monitor sensitive policy changes.
  • Use temporary credentials whenever possible.
  • Review permissions regularly.
  • Protect high-risk operations with additional authorization controls.

Example Least-Privilege DynamoDB Policy

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:PutItem",
"dynamodb:GetItem"
],
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT_ID:table/BlockchainTransactions"
}
]
}
Replace  REGION  and  ACCOUNT_ID  with the correct deployment values.
This example grants only the specified DynamoDB actions on one table.
Additional permissions may be necessary for other application operations.

8. Protecting Cryptographic Keys with AWS KMS

Cryptographic signing is one of the most sensitive operations in blockchain systems.
A private key may authorize transactions that cannot be reversed after finalization.
AWS KMS supports key management and cryptographic operations for supported algorithms.
However, compatibility must be evaluated carefully.
For example, Ethereum transactions commonly use secp256k1 signatures and require blockchain-specific signature encoding and transaction construction.
A KMS-based signing workflow must correctly implement the required signing algorithm, digest handling, signature formatting, and transaction serialization.
AWS KMS is not a complete cryptocurrency wallet.

Recommended Controls

  1. Restrict signing permissions to dedicated services.
  1. Separate transaction construction from transaction authorization.
  1. Enforce transaction limits.
  1. Validate destination addresses.
  1. Require independent approval for high-risk transactions.
  1. Monitor signing activity.
  1. Maintain incident response procedures for suspected compromise.
Important: A hardware-backed key does not prevent theft if an attacker can make unrestricted, authorized signing requests.
A secure design must protect both the key and the transaction approval process.

9. Monitoring Blockchain Infrastructure with CloudWatch

Blockchain applications require visibility into both traditional application metrics and blockchain-specific activity.
Useful operational metrics include:
  • JSON-RPC request latency.
  • Failed RPC requests.
  • Transaction submission errors.
  • Pending transaction count.
  • Transaction confirmation delays.
  • Lambda execution failures.
  • API Gateway error rates.
  • Unexpected signing requests.

Example CloudWatch Custom Metric

import boto3

cloudwatch = boto3.client("cloudwatch")

def publish_rpc_failure():
cloudwatch.put_metric_data(
Namespace="Blockchain/Application",
MetricData=[
{
"MetricName": "RPCFailures",
"Value": 1,
"Unit": "Count"
}
]
)
This metric can be used to build CloudWatch alarms.
For example, an alarm could notify the operations team when the number of RPC failures exceeds a defined threshold.
CloudWatch does not automatically understand every blockchain transaction or smart-contract event.
Blockchain-specific monitoring requires custom instrumentation or specialized integrations.

10. Event-Driven Blockchain Monitoring

Blockchain networks generate events that can be useful for application workflows.
For example, a smart contract may emit an event when a token transfer occurs.
Applications can consume these events and trigger off-chain processing.

Example Event-Driven Workflow

Ethereum Smart Contract
|
v
Blockchain Event
|
v
Blockchain Listener
|
v
Amazon EventBridge
|
v
AWS Lambda
|
v
Amazon DynamoDB
|
v
Application Notification
A blockchain listener must retrieve and validate the relevant on-chain events before publishing them to EventBridge.
The listener can run in a suitable AWS compute environment or use supported managed blockchain event capabilities where available.

Blockchain Finality Considerations

Blockchain events may be observed before a transaction reaches the application's required level of finality.
Depending on the network, chain reorganizations or changes in transaction status may occur.
Applications should therefore:
  • Track transaction confirmations or finalized blocks.
  • Handle duplicate events.
  • Support idempotent processing.
  • Account for reorganizations.
  • Avoid treating unconfirmed activity as final settlement.
These controls are especially important for financial applications.

11. Smart Contract Security and AWS

Smart contracts introduce security risks that differ from traditional web applications.
Common vulnerability categories include:
  • Reentrancy.
  • Broken access control.
  • Oracle manipulation.
  • Incorrect authorization logic.
  • Unsafe external calls.
  • Signature replay vulnerabilities.
  • Business logic flaws.
  • Upgradeability misconfigurations.
AWS infrastructure security services do not automatically detect all these vulnerabilities.
A comprehensive security program should combine AWS controls with specialized smart-contract security tools.
Examples include:
  • Slither for static analysis.
  • Foundry for testing and fuzzing.
  • Echidna for property-based fuzzing.
  • Formal verification where appropriate.
  • Independent smart-contract audits.
  • Bug bounty programs.

Security Testing Workflow

Smart Contract Development
|
v
Unit Testing
|
v
Static Analysis
|
v
Fuzzing and Invariants
|
v
Independent Review
|
v
Testnet Deployment
|
v
Production Deployment
|
v
Continuous On-Chain Monitoring
AWS can host CI/CD infrastructure and support automated testing workflows, but blockchain-specific analysis must be implemented separately.

12. Threat Detection with Amazon GuardDuty

Amazon GuardDuty helps detect potentially malicious activity in supported AWS environments.
For blockchain applications, GuardDuty may help identify:
  • Suspicious IAM credential usage.
  • Potentially compromised EC2 workloads.
  • Unusual cloud API activity.
  • Malicious network communications.
  • Certain cryptocurrency mining indicators.
  • Supported container-related threats.
However, GuardDuty does not automatically detect fraudulent Ethereum transactions or malicious smart-contract behavior.
Organizations should correlate GuardDuty findings with application logs, transaction authorization records, and on-chain monitoring data.

13. Production Best Practices

Before deploying blockchain applications to production, organizations should establish a comprehensive security and reliability strategy.

Infrastructure Security

  • Use separate AWS accounts for sensitive environments.
  • Apply least-privilege IAM policies.
  • Restrict network access.
  • Enable appropriate audit logging.
  • Continuously assess supported workloads for vulnerabilities.
  • Protect secrets and cryptographic keys.

Application Security

  • Validate all API inputs.
  • Enforce authentication and authorization.
  • Implement rate limiting.
  • Use secure dependency management.
  • Perform regular penetration testing.
  • Review smart-contract interactions.

Blockchain Security

  • Validate transaction destinations.
  • Implement transaction value limits.
  • Protect signing operations.
  • Monitor abnormal transaction patterns.
  • Handle blockchain reorganizations.
  • Define transaction finality requirements.
  • Perform smart-contract audits.

Operational Resilience

  • Monitor RPC endpoint availability.
  • Implement retries with exponential backoff.
  • Use idempotent event processing.
  • Define incident response procedures.
  • Test disaster recovery plans.
  • Monitor infrastructure and blockchain-related costs.

14. Limitations and Architectural Trade-Offs

AWS provides useful building blocks for blockchain applications, but it does not eliminate every risk.
Important considerations include:
Decentralization
Off-chain application components hosted on AWS remain dependent on AWS infrastructure and service availability.
Cryptographic compatibility
Not every AWS cryptographic service supports every blockchain signing format or custody architecture.
Smart-contract vulnerabilities
Traditional cloud security tools do not replace blockchain-specific security analysis.
Operational costs
Managed blockchain access, API requests, compute, logging, and data storage can introduce ongoing expenses.
Blockchain finality
Applications must account for the settlement characteristics of the blockchain network they use.
Regulatory requirements
Financial and digital asset applications may be subject to jurisdiction-specific legal, compliance, and custody obligations.



Conclusion

Blockchain applications require more than smart contracts and decentralized networks.
They also need reliable APIs, secure authentication, protected signing operations, monitoring, data processing, and incident response capabilities.
AWS provides services that can support these requirements through managed blockchain connectivity, serverless computing, database services, cryptographic key management, and security monitoring.
Amazon Managed Blockchain Access can reduce the operational burden of connecting to supported blockchain networks, while AWS Lambda, API Gateway, and DynamoDB can support scalable off-chain application workflows.
However, secure blockchain architecture requires a clear separation between infrastructure security, transaction authorization, and smart-contract security.
The most effective approach is to combine cloud-native security controls with blockchain-specific protections, ensuring that neither a compromised cloud identity nor a vulnerable application can independently authorize unrestricted movement of digital assets.



References

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article