-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
919a342
commit 15b4c45
Showing
22 changed files
with
2,639 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": "es:*", | ||
"Resource": "arn:aws:es:us-east-2:242040583208:domain/testdomain/*" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
aws::vpc vpc-example | ||
cidr-block: "10.0.0.0/16" | ||
provide-ipv6-cidr-block: true | ||
|
||
tags: { | ||
Name: "opensearch-domain-example" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-1 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1a | ||
cidr-block: "10.0.0.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-example-1" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-2 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1b | ||
cidr-block: "10.0.1.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-example-2" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-3 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1c | ||
cidr-block: "10.0.2.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-example-3" | ||
} | ||
end | ||
|
||
aws::security-group example-security-group | ||
name: "opensearch-domain-example" | ||
vpc: $(aws::vpc vpc-example) | ||
description: "security group example for es" | ||
end | ||
|
||
aws::opensearch-domain opensearch-domain-example | ||
domain-name: "testdomain" | ||
open-search-version: "OpenSearch_1.0" | ||
|
||
ebs-options | ||
enable-ebs: true | ||
volume-type: standard | ||
volume-count: 10 | ||
end | ||
|
||
node-to-node-encryption-options | ||
enable-node-to-node-encryption: true | ||
end | ||
|
||
encryption-at-rest-options | ||
enable-encryption-at-rest: true | ||
end | ||
|
||
cluster-configuration | ||
enable-zone-awareness: true | ||
instance-count: 4 | ||
|
||
zone-awareness-configuration | ||
availability-zone-count: 2 | ||
end | ||
end | ||
|
||
domain-endpoint-options | ||
enforce-https: true | ||
end | ||
|
||
advanced-security-options | ||
enable-advanced-security-options: true | ||
enable-internal-user-database: true | ||
|
||
master-user-options | ||
master-username: "masteruser" | ||
master-password: "MasterUser1!" | ||
end | ||
end | ||
|
||
access-policies: "access-policy.json" | ||
|
||
advanced-options: { | ||
"indices.query.bool.max_clause_count": "1026", | ||
"rest.action.multi.allow_explicit_index": "true", | ||
"override_main_response_version": "false" | ||
} | ||
|
||
tags: { | ||
"description": "Test Domain" | ||
} | ||
|
||
vpc-options | ||
subnets: [ | ||
$(aws::subnet example-subnet-1), | ||
$(aws::subnet example-subnet-3) | ||
] | ||
|
||
security-groups: [ | ||
$(aws::security-group example-security-group) | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
aws::vpc vpc-example | ||
cidr-block: "10.0.0.0/16" | ||
provide-ipv6-cidr-block: true | ||
|
||
tags: { | ||
Name: "opensearch-domain-vpc-endpoint-example" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-1 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1a | ||
cidr-block: "10.0.0.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-vpc-endpoint-example-1" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-2 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1b | ||
cidr-block: "10.0.1.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-vpc-endpoint-example-2" | ||
} | ||
end | ||
|
||
aws::subnet example-subnet-3 | ||
vpc: $(aws::vpc vpc-example) | ||
availability-zone: us-east-1c | ||
cidr-block: "10.0.2.0/24" | ||
|
||
tags: { | ||
Name: "opensearch-domain-vpc-endpoint-example-3" | ||
} | ||
end | ||
|
||
aws::security-group example-security-group | ||
name: "opensearch-domain-vpc-endpoint-example" | ||
vpc: $(aws::vpc vpc-example) | ||
description: "security group example for es" | ||
end | ||
|
||
aws::opensearch-vpc-endpoint vpc-endpoint | ||
domain: "arn:aws:es:us-east-1:242040583208:domain/dj-test" | ||
vpc-options | ||
subnets: [ | ||
$(aws::subnet example-subnet-1), | ||
$(aws::subnet example-subnet-3) | ||
] | ||
|
||
security-groups: [ | ||
$(aws::security-group example-security-group) | ||
] | ||
end | ||
end |
127 changes: 127 additions & 0 deletions
127
src/main/java/gyro/aws/opensearch/OpenSearchAdvancedSecurityOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright 2024, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.aws.opensearch; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import gyro.aws.Copyable; | ||
import gyro.core.resource.Diffable; | ||
import gyro.core.resource.Updatable; | ||
import gyro.core.validation.Required; | ||
import gyro.core.validation.ValidationError; | ||
import software.amazon.awssdk.services.opensearch.model.AdvancedSecurityOptions; | ||
import software.amazon.awssdk.services.opensearch.model.AdvancedSecurityOptionsInput; | ||
|
||
public class OpenSearchAdvancedSecurityOptions extends Diffable implements Copyable<AdvancedSecurityOptions> { | ||
|
||
private Boolean enableAdvancedSecurityOptions; | ||
private Boolean enableInternalUserDatabase; | ||
private OpenSearchMasterUserOptions masterUserOptions; | ||
|
||
/** | ||
* Enable advanced security for the domain. | ||
*/ | ||
@Updatable | ||
@Required | ||
public Boolean getEnableAdvancedSecurityOptions() { | ||
return enableAdvancedSecurityOptions; | ||
} | ||
|
||
public void setEnableAdvancedSecurityOptions(Boolean enableAdvancedSecurityOptions) { | ||
this.enableAdvancedSecurityOptions = enableAdvancedSecurityOptions; | ||
} | ||
|
||
/** | ||
* Enable the Internal User Database. | ||
*/ | ||
@Updatable | ||
public Boolean getEnableInternalUserDatabase() { | ||
return enableInternalUserDatabase; | ||
} | ||
|
||
public void setEnableInternalUserDatabase(Boolean enableInternalUserDatabase) { | ||
this.enableInternalUserDatabase = enableInternalUserDatabase; | ||
} | ||
|
||
/** | ||
* The master user options configuration. Can only be set if ``enable-advanced-security-options`` is set to ``true``. | ||
* | ||
* @subresource gyro.aws.opensearch.OpenSearchMasterUserOptions | ||
*/ | ||
@Updatable | ||
public OpenSearchMasterUserOptions getMasterUserOptions() { | ||
return masterUserOptions; | ||
} | ||
|
||
public void setMasterUserOptions(OpenSearchMasterUserOptions masterUserOptions) { | ||
this.masterUserOptions = masterUserOptions; | ||
} | ||
|
||
@Override | ||
public void copyFrom(AdvancedSecurityOptions model) { | ||
setEnableAdvancedSecurityOptions(model.enabled()); | ||
setEnableInternalUserDatabase(model.internalUserDatabaseEnabled()); | ||
|
||
// Not resetting the masterUserOptions since the api doesn't return the credentials for the master user. | ||
} | ||
|
||
@Override | ||
public String primaryKey() { | ||
return ""; | ||
} | ||
|
||
AdvancedSecurityOptionsInput toAdvancedSecurityOptionsInput() { | ||
AdvancedSecurityOptionsInput.Builder builder = AdvancedSecurityOptionsInput.builder() | ||
.enabled(getEnableAdvancedSecurityOptions()); | ||
|
||
if (getEnableInternalUserDatabase() != null) { | ||
builder.internalUserDatabaseEnabled(getEnableInternalUserDatabase()); | ||
} | ||
|
||
if (getMasterUserOptions() != null) { | ||
builder.masterUserOptions(getMasterUserOptions().toMasterUserOptions()); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public List<ValidationError> validate(Set<String> configuredFields) { | ||
List<ValidationError> errors = new ArrayList<>(); | ||
|
||
if (getEnableAdvancedSecurityOptions().equals(Boolean.FALSE) && ( | ||
configuredFields.contains("enable-internal-user-database") || configuredFields.contains( | ||
"master-user-options"))) { | ||
errors.add(new ValidationError( | ||
this, | ||
null, | ||
"The 'enable-internal-user-database' or 'master-user-options' can only be set if 'enable-advanced-security-options' is set to 'true'.")); | ||
} | ||
|
||
if (getEnableAdvancedSecurityOptions().equals(Boolean.TRUE) | ||
&& !configuredFields.contains("master-user-options")) { | ||
errors.add(new ValidationError( | ||
this, | ||
"master-user-options", | ||
"The 'master-user-options' is required if 'enable-advanced-security-options' is set to 'true'.")); | ||
} | ||
|
||
return errors; | ||
} | ||
} |
Oops, something went wrong.