-
Notifications
You must be signed in to change notification settings - Fork 38
CMK support #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMK support #137
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicusX, many thanks for your efforts here. Based on our offline discussions, I think we can further limit this policy suggested below.
infrastructure/CMK/README.md
Outdated
"infrastructure.kinesisanalytics.amazonaws.com" | ||
] | ||
}, | ||
"Action": "kms:*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Action": "kms:*", | |
"Action": [ "kms:DescribeKey", "kms:Decrypt", "kms:GenerateDataKey", "kms:GenerateDataKeyWithoutPlaintext", "kms:CreateGrant", ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated (just removing the trailing comma)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments on key policy
infrastructure/CMK/msf-kms-key.yaml
Outdated
- Sid: 'Allow Operator to use key for durable state via Managed Flink' | ||
Effect: Allow | ||
Principal: | ||
AWS: !Ref OperatorUserArn | ||
Action: | ||
- 'kms:Decrypt' | ||
- 'kms:GenerateDataKey' | ||
Resource: '*' | ||
Condition: | ||
StringEquals: | ||
'kms:EncryptionContext:aws:kinesisanalytics:arn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
'kms:ViaService': !Sub 'kinesisanalytics.${AWS::Region}.amazonaws.com' | ||
|
||
- Sid: 'Allow Operator to use key for running state via Managed Flink' | ||
Effect: Allow | ||
Principal: | ||
AWS: !Ref OperatorUserArn | ||
Action: | ||
- 'kms:Decrypt' | ||
- 'kms:GenerateDataKeyWithoutPlaintext' | ||
Resource: '*' | ||
Condition: | ||
StringEquals: | ||
'kms:EncryptionContext:aws:kinesisanalytics:arn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
'kms:ViaService': !Sub 'kinesisanalytics.${AWS::Region}.amazonaws.com' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge these to become the following instead
"Sid": "AllowOperatorToConfigureAppToUseKeyForApplicationState",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::Application-account-ID:role/Operator"
},
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey",
"kms:GenerateDataKeyWithoutPlaintext"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"kms:EncryptionContext:aws:kinesisanalytics:arn":
"arn:aws:kinesisanalytics:Aws-region:Application-account-ID:application/MyCmkApplication",
"kms:ViaService": "kinesisanalytics.Aws-region.amazonaws.com"
}
}
infrastructure/CMK/msf-kms-key.yaml
Outdated
- Sid: 'Allow Managed Flink application to decrypt durable state storage' | ||
Effect: Allow | ||
Principal: | ||
Service: 'kinesisanalytics.amazonaws.com' | ||
Action: | ||
- 'kms:Decrypt' | ||
- 'kms:GenerateDataKey' | ||
Resource: '*' | ||
Condition: | ||
StringEquals: | ||
'aws:SourceArn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
'kms:EncryptionContext:aws:kinesisanalytics:arn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
'aws:SourceAccount': !Ref 'AWS::AccountId' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to split this into the following for the time being as Source context is not provided during decrypt
{
"Sid": "AllowMSFServiceToGenerateDataKeyForDurableState",
"Effect": "Allow",
"Principal": {
"Service": "kinesisanalytics.amazonaws.com"
},
"Action": [
"kms:GenerateDataKey"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:SourceArn":
"arn:aws:kinesisanalytics:Aws-region:Application-account-ID:application/MyCmkApplication",
"kms:EncryptionContext:aws:kinesisanalytics:arn":
"arn:aws:kinesisanalytics:Aws-region:Application-account-ID:application/MyCmkApplication",
"aws:SourceAccount": "Application-account-ID"
}
}
},
{
"Sid": "AllowMSFServiceToDecryptForDurableState",
"Effect": "Allow",
"Principal": {
"Service": "kinesisanalytics.amazonaws.com"
},
"Action": [
"kms:Decrypt"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"kms:EncryptionContext:aws:kinesisanalytics:arn":
"arn:aws:kinesisanalytics:Aws-region:Application-account-ID:application/MyCmkApplication"
}
}
}
infrastructure/CMK/msf-kms-key.yaml
Outdated
Effect: Allow | ||
Principal: | ||
Service: | ||
- 'kinesisanalytics.amazonaws.com' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove 'kinesisanalytics.amazonaws.com' from here
@leekeiabstraction they key policy should be fixed now. Please triple-check |
infrastructure/CMK/msf-kms-key.yaml
Outdated
'aws:SourceArn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
'aws:SourceAccount': !Ref 'AWS::AccountId' | ||
|
||
- Sid: 'FIXME Allow Managed Flink application to generate data key for durable state storage' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a FIXME here.
infrastructure/CMK/msf-kms-key.yaml
Outdated
StringEquals: | ||
'kms:EncryptionContext:aws:kinesisanalytics:arn': !Sub 'arn:aws:kinesisanalytics:${AWS::Region}:${AWS::AccountId}:application/${ApplicationName}' | ||
|
||
- Sid: 'Allow Managed Flink application to decrypt running application storage' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Allow Managed Flink application to use key for running application storage
@leekeiabstraction fixed the two SIDs |
Purpose of the change
CFN template examples for CMK support