MSk Cluster에 접속하여 topic, message를 제어하기 위해서 client 설정이 필요하다.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kafka-cluster:Connect",
"kafka-cluster:AlterCluster",
"kafka-cluster:DescribeCluster"
],
"Resource": [
"arn:aws:kafka:{region}:{account number}:cluster/{cluster name}/*"
]
},
{
"Effect": "Allow",
"Action": [
"kafka-cluster:*Topic*",
"kafka-cluster:WriteData",
"kafka-cluster:ReadData"
],
"Resource": [
"arn:aws:kafka:{region}:{account number}:topic/{cluster name}/*"
]
},
{
"Effect": "Allow",
"Action": [
"kafka-cluster:AlterGroup",
"kafka-cluster:DescribeGroup"
],
"Resource": [
"arn:aws:kafka:{region}:{account number}:group/{cluster name}/*"
]
}
]
}
sudo yum -y install java-11
wget https://archive.apache.org/dist/kafka/2.8.1/kafka_2.13-2.8.1.tgz
tar -xzf kafka_2.13-2.8.1.tgz
cd kafka_2.13-2.8.1.tgz/libs
wget https://github.com/aws/aws-msk-iam-auth/releases/download/v1.1.1/aws-msk-iam-auth-1.1.1-all.jar
security.protocol=SASL_SSL
sasl.mechanism=AWS_MSK_IAM
sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required;
sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler
MSK Cluster의 Client Bootstrap Server 정보 가져오기
topic 생성 command
/home/ec2-user/kafka_2.13-2.8.1/bin/kafka-topics.sh --create --bootstrap-server {Client Bootstrap Server} --command-config /home/ec2-user/kafka_2.13-2.8.1/bin/client.properties --replication-factor 3 --partitions 1 --topic {topic_name}
/home/ec2-user/kafka_2.13-2.8.1/bin/kafka-topics.sh --bootstrap-server {Client Bootstrap Server} --command-config /home/ec2-user/kafka_2.13-2.8.1/bin/client.properties --list