mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(glue): catalog resource policy and Data Catalog encryption settings (#4027)
* feat(glue): catalog resource policy and Data Catalog encryption settings Add PutResourcePolicy, GetResourcePolicy, GetResourcePolicies and DeleteResourcePolicy with the PolicyExistsCondition and PolicyHashCondition checks Terraform relies on, and Get/Put DataCatalogEncryptionSettings with the documented defaults. ConnectionPasswordEncryption is applied rather than stored: while it is on, CreateConnection and UpdateConnection encrypt PASSWORD and the four Kafka passwords with the configured KMS key and keep them under their documented ENCRYPTED_* names, so reads return the ciphertext and a missing key is GlueEncryptionException. Closes #4023 * docs(glue): cite the source for connection password encryption timing and drop an unsourced claim The developer guide states that whether a password is encrypted was decided when the connection was created or updated, which is the source for connections keeping their plaintext; the missing-key error is described as the error CreateConnection and UpdateConnection list rather than as AWS behaviour. Also replaces a var in the compat test with the explicit type.
This commit is contained in:
1 parent
2d56d85e9e
commit
628952ecf0
12 files changed
+899
-12
No files matched your search
@@ -7,12 +7,21 @@ import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.glue.GlueClient;
|
||||
import software.amazon.awssdk.services.glue.model.BatchCreatePartitionRequest;
|
||||
import software.amazon.awssdk.services.glue.model.BatchDeleteConnectionRequest;
|
||||
import software.amazon.awssdk.services.glue.model.ConditionCheckFailureException;
|
||||
import software.amazon.awssdk.services.glue.model.DeleteResourcePolicyRequest;
|
||||
import software.amazon.awssdk.services.glue.model.ExistCondition;
|
||||
import software.amazon.awssdk.services.glue.model.GetResourcePoliciesRequest;
|
||||
import software.amazon.awssdk.services.glue.model.GetResourcePolicyRequest;
|
||||
import software.amazon.awssdk.services.glue.model.GetResourcePolicyResponse;
|
||||
import software.amazon.awssdk.services.glue.model.GetDataCatalogEncryptionSettingsRequest;
|
||||
import software.amazon.awssdk.services.glue.model.PutResourcePolicyRequest;
|
||||
import software.amazon.awssdk.services.glue.model.BatchDeleteConnectionResponse;
|
||||
import software.amazon.awssdk.services.glue.model.Connection;
|
||||
import software.amazon.awssdk.services.glue.model.ConnectionInput;
|
||||
import software.amazon.awssdk.services.glue.model.ConnectionPropertyKey;
|
||||
import software.amazon.awssdk.services.glue.model.ConnectionType;
|
||||
import software.amazon.awssdk.services.glue.model.CreateConnectionRequest;
|
||||
import software.amazon.awssdk.services.glue.model.DataCatalogEncryptionSettings;
|
||||
import software.amazon.awssdk.services.glue.model.CreateConnectionResponse;
|
||||
import software.amazon.awssdk.services.glue.model.DeleteConnectionRequest;
|
||||
import software.amazon.awssdk.services.glue.model.GetConnectionRequest;
|
||||
@@ -640,6 +649,55 @@ class GlueCatalogTest {
|
||||
assertThat(batch.errors()).containsOnlyKeys(CONNECTION_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("The catalog resource policy follows the create, update and delete conditions Terraform sends")
|
||||
void catalogResourcePolicyLifecycle() {
|
||||
String policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
|
||||
+ "\"Principal\":{\"AWS\":\"arn:aws:iam::111122223333:root\"},\"Action\":\"glue:GetTable\",\"Resource\":\"*\"}]}";
|
||||
String policyV2 = policy.replace("glue:GetTable", "glue:GetTables");
|
||||
// Start from no policy; the catalog is shared with other tests.
|
||||
try {
|
||||
glue.deleteResourcePolicy(DeleteResourcePolicyRequest.builder().build());
|
||||
}
|
||||
catch (EntityNotFoundException ignored) {}
|
||||
|
||||
String hash = glue.putResourcePolicy(PutResourcePolicyRequest.builder()
|
||||
.policyInJson(policy)
|
||||
.policyExistsCondition(ExistCondition.NOT_EXIST)
|
||||
.build()).policyHash();
|
||||
GetResourcePolicyResponse read = glue.getResourcePolicy(GetResourcePolicyRequest.builder().build());
|
||||
assertThat(read.policyInJson()).isEqualTo(policy);
|
||||
assertThat(read.policyHash()).isEqualTo(hash);
|
||||
assertThat(read.createTime()).isNotNull();
|
||||
assertThat(read.updateTime()).isNotNull();
|
||||
|
||||
assertThatThrownBy(() -> glue.putResourcePolicy(PutResourcePolicyRequest.builder()
|
||||
.policyInJson(policyV2)
|
||||
.policyExistsCondition(ExistCondition.NOT_EXIST)
|
||||
.build()))
|
||||
.isInstanceOf(ConditionCheckFailureException.class);
|
||||
|
||||
String hash2 = glue.putResourcePolicy(PutResourcePolicyRequest.builder()
|
||||
.policyInJson(policyV2)
|
||||
.policyExistsCondition(ExistCondition.MUST_EXIST)
|
||||
.policyHashCondition(hash)
|
||||
.build()).policyHash();
|
||||
assertThat(glue.getResourcePolicy(GetResourcePolicyRequest.builder().build()).policyInJson()).isEqualTo(policyV2);
|
||||
assertThat(glue.getResourcePolicies(GetResourcePoliciesRequest.builder().build()).getResourcePoliciesResponseList()).hasSize(1);
|
||||
|
||||
assertThatThrownBy(() -> glue.deleteResourcePolicy(DeleteResourcePolicyRequest.builder()
|
||||
.policyHashCondition(hash).build()))
|
||||
.isInstanceOf(ConditionCheckFailureException.class);
|
||||
glue.deleteResourcePolicy(DeleteResourcePolicyRequest.builder().policyHashCondition(hash2).build());
|
||||
assertThatThrownBy(() -> glue.getResourcePolicy(GetResourcePolicyRequest.builder().build()))
|
||||
.isInstanceOf(EntityNotFoundException.class);
|
||||
|
||||
DataCatalogEncryptionSettings settings = glue.getDataCatalogEncryptionSettings(GetDataCatalogEncryptionSettingsRequest.builder().build())
|
||||
.dataCatalogEncryptionSettings();
|
||||
assertThat(settings.encryptionAtRest().catalogEncryptionModeAsString()).isEqualTo("DISABLED");
|
||||
assertThat(settings.connectionPasswordEncryption().returnConnectionPasswordEncrypted()).isFalse();
|
||||
}
|
||||
|
||||
private static TableInput tableInput(String description) {
|
||||
return tableInput(TABLE_NAME, description);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user