references/environment-setup.mdMarkdown7 KBView on GitHub
This guide provides setup instructions for Apache Flink development targeting Amazon Managed Service for Apache Flink deployment. The setup ensures compatibility with Managed Service for Apache Flink requirements while enabling efficient local development and testing workflows using Docker containers that mirror the Managed Service for Apache Flink environment. For new applications, default to Flink 2.2. For existing applications, use the user’s current Flink version.
Before starting, ensure you have:
Docker is required for running Flink, Kafka, LocalStack, and other infrastructure locally for testing. Ensure Docker is installed.
Verification:
docker --version
docker-compose --version
docker run hello-worldWhile Flink runs in containers, JDK is still needed for compilation and IDE support. Flink 1.20 requires Java 11. Flink 2.2 requires Java 17 (Java 21 also supported).
Verification:
java -version
javac -version
echo $JAVA_HOMECreate a comprehensive Docker Compose setup that mirrors the Managed Service for Apache Flink environment. Adjust the Flink image tag to match your target version:
flink:1.20-java11flink:2.2-java17Create docker-compose.yml in your project root:
version: '3.8'
# Set FLINK_IMAGE_TAG in your environment or .env file:
# Flink 1.20: FLINK_IMAGE_TAG=1.20-java11
# Flink 2.2: FLINK_IMAGE_TAG=2.2-java17
services:
# Flink JobManager
jobmanager:
image: flink:${FLINK_IMAGE_TAG:-2.2-java17}
hostname: jobmanager
container_name: flink-jobmanager
ports:
- "8081:8081"
command: jobmanager
environment:
- |
FLINK_PROPERTIES=
1. Create Project Structure:
# Create Managed Service for Apache Flink project directory
mkdir my-msf-app
cd my-msf-app
# Create required directories
mkdir -p flink-jobs src/main/java src/test/java
# Copy docker-compose.yml to project root2. Start Docker Environment:
# Start all services
docker-compose up -d
# Verify services are running
docker-compose ps
# Check taskmanager logs for submitted Flink jobs
docker-compose logs taskmanager
# Check Flink Web UI
open http://localhost:8081
# Check Kafka
docker-compose exec kafka kafka-topics --bootstrap-server localhost:9092 --listBuild the JAR in local mode to include Managed Service for Apache Flink provided dependencies:
# For Flink 1.20 (Java 11):
mvn clean package -Plocal -q
# For Flink 2.2 (Java 17):
# Set JAVA_HOME to your Java 17 installation path before building
export JAVA_HOME=<path-to-java-17>
mvn clean package -Plocal -q
cp target/my-flink-app-1.0.jar flink-jobs/
docker exec flink-jobmanager flink run /opt/flink/jobs/my-flink-app-1.0.jarSee dependency-management.md for examples of dependencies and pom.xml requried for Managed Service for Apache Flink.
AWS CLI Managed Service for Apache Flink Commands:
# List Managed Service for Apache Flink applications
aws kinesisanalyticsv2 list-applications
# Describe Managed Service for Apache Flink application
aws kinesisanalyticsv2 describe-application --application-name my-app
# Create savepoint
aws kinesisanalyticsv2 create-application-snapshot --application-name my-app --snapshot-name my-snapshot