Skip to content

Commit 634a581

Browse files
authored
Update Kinesis example readme explaining cross-account (#90)
1 parent 44b26b5 commit 634a581

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

java/KinesisConnectors/README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Every parameter in the `InputStream0` group is passed to the Kinesis consumer, a
4040

4141
See Flink Kinesis connector docs](https://nightlies.apache.org/flink/flink-docs-release-1.19/docs/connectors/datastream/kinesis/) for details about configuring the Kinesis conector.
4242

43-
To configure the applicaton on Managed Service for Apache Flink, set up these parameter in the *Runtime properties*.
43+
To configure the application on Managed Service for Apache Flink, set up these parameter in the *Runtime properties*.
4444

4545
To configure the application for running locally, edit the [json file](resources/flink-application-properties-dev.json).
4646

@@ -55,3 +55,68 @@ See [Running examples locally](../running-examples-locally.md) for details.
5555
You can use [Kinesis Data Generator](https://github.com/awslabs/amazon-kinesis-data-generator),
5656
also available in a [hosted version](https://awslabs.github.io/amazon-kinesis-data-generator/web/producer.html),
5757
to generate random data to Kinesis Data Stream and test the application.
58+
59+
---
60+
61+
## Cross-account access to Kinesis
62+
63+
You can use the Kinesis source and sink to read and write to a Kinesis Stream in a different account,
64+
by configuring the connector to assume an IAM Role in the stream account.
65+
66+
This requires:
67+
1. An IAM Role in the stream account with sufficient permissions to read or write the Kinesis stream, and allow the Managed Flink application account to assume this role.
68+
2. Add to the Managed Flink application IAM role permissions to assume the previous role.
69+
3. Configure the Kinesis source or sink to assume the role.
70+
71+
> Note: this approach also works with the legacy `FlinkKinesisConsumer`.
72+
73+
### IAM Role in the stream account
74+
75+
In the stream account, create a role with permissions to read or write the stream.
76+
See [Kinesis Data Streams documentation](https://docs.aws.amazon.com/streams/latest/dev/controlling-access.html#kinesis-using-iam-examples) for details.
77+
78+
Add a Trust Relationship to this role, allowing the application account to assume it:
79+
80+
```json
81+
{
82+
"Version": "2012-10-17",
83+
"Statement": [
84+
{
85+
"Effect": "Allow",
86+
"Principal": {
87+
"AWS": "arn:aws:iam::<application-account-id>:root"
88+
},
89+
"Action": "sts:AssumeRole",
90+
"Condition": {}
91+
}
92+
]
93+
}
94+
```
95+
96+
### Application IAM Role
97+
98+
Add the following policy to the Managed Flink application role, allowing the application to assume the role in the stream account:
99+
100+
```json
101+
{
102+
"Version": "2012-10-17",
103+
"Statement": [
104+
{
105+
"Sid": "Statement1",
106+
"Effect": "Allow",
107+
"Action": "sts:AssumeRole",
108+
"Resource": "arn:aws:iam::<stream-account-ID>:role/<role-in-stream-account-to-assume>"
109+
}
110+
]
111+
}
112+
```
113+
114+
### Connector configuration
115+
116+
Pass the following configuration parameters to the Kinesis source or sink:
117+
118+
| Configuration | Value |
119+
|---------------------------------------------|-----------------------------------------------------------------------------|
120+
| `aws.credentials.provider` | `ASSUME_ROLE` |
121+
| `aws.credentials.provider.role.arn` | ARN of the role in the stream account |
122+
| `aws.credentials.provider.role.sessionName` | Any string used as name for the STS session. Must be unique in the account. |

0 commit comments

Comments
 (0)