Use AWS IAM assume role credentials provider
The Aiven for Apache Kafka® S3 sink connector moves data from an Aiven for Apache Kafka cluster to Amazon S3 for long-term storage.
You can connect the S3 sink connector to Amazon S3 using either:
- Long-term AWS credentials (
ACCESS_KEY_IDandSECRET_ACCESS_KEY) - AWS IAM assume role credentials (recommended)
When you use IAM assume role credentials, the connector requests short-term credentials each time it writes data to the S3 bucket.
To use IAM assume role credentials:
- Request a unique IAM user from Aiven support.
- Create an AWS cross-account access role.
- Create a Kafka Connect S3 sink connector.
Request a unique IAM user from Aiven support
Each Aiven project has a dedicated IAM user. Aiven does not share IAM users or roles
across customers. Contact Aiven support at support@aiven.io to request:
- An IAM user ARN
- An External ID (used to identify your role)
Example:
- IAM user:
arn:aws:iam::012345678901:user/sample-project-user - External ID:
2f401145-06a0-4938-8e05-2d67196a0695
The cross-account role you create provides access to one Aiven project only.
Create an AWS cross-account access role
- Sign in to the AWS console.
- Go to IAM > Roles > Create role.
- Select Another AWS account as the trusted entity type.
- Enter the Account ID.
This is the numeric string in the IAM user ARN between
aws:iam::and:user/. Example:012345678901 - Select Require external ID and enter the External ID provided by Aiven support.
- Add permissions to allow writing to an S3 bucket. The following permissions are required:
s3:GetObjects3:PutObjects3:AbortMultipartUploads3:ListMultipartUploadPartss3:ListBucketMultipartUploads
- Optional: Add tags.
- Enter a name for the role. Example:
AivenKafkaConnectSink - To restrict access, edit the trust relationship for the new role:
- Go to Trust relationships > Edit trust relationship
- Set the IAM user as the
Principal.
- Copy the new IAM role ARN. You will need it in the connector configuration.
Create a Kafka Connect S3 sink connector
Create the connector as described in the S3 sink connector documentation.
To use IAM assume role credentials, remove these parameters from the connector configuration:
aws.access.key.idaws.secret.access.key
Add these parameters:
aws.sts.role.arn: ARN of the IAM role created in AWS.aws.sts.role.external.id: External ID provided by Aiven support.
Optional parameters:
aws.sts.role.session.name: Session identifier for the task. Appears in AWS CloudTrail logs and helps distinguish tasks within the same project.aws.sts.config.endpoint: Security Token Service (STS) endpoint. Use the endpoint in the same region as the S3 bucket for better performance. Example: For regioneu-north-1, sethttps://sts.eu-north-1.amazonaws.com. For the list of STS endpoints, see the AWS documentation.
Example configuration file
Save the following as s3_sink.json:
{
"name": "<CONNECTOR_NAME>",
"connector.class": "io.aiven.kafka.connect.s3.AivenKafkaConnectS3SinkConnector",
"key.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"topics": "<TOPIC_NAME>",
"aws.sts.role.arn": "<AWS_ROLE_ARN>",
"aws.sts.role.external.id": "<AWS_IAM_USER_EXTERNAL_ID>",
"aws.sts.role.session.name": "<AWS_STS_SESSION_NAME>",
"aws.sts.config.endpoint": "<AWS_STS_ENDPOINT>",
"aws.s3.bucket.name": "<AWS_S3_BUCKET_NAME>",
"aws.s3.region": "<AWS_S3_REGION>"
}
For the full list of S3 sink connector settings and examples, see the S3 sink connector documentation.