Comments (5)
Hmm, for whatever reason it looks like the CDK is using a custom resource lambda to set the access policy rather than using the access policy property on the CloudFormation resource
It's technically possible (but messy) to check the custom resource.
This will need further research to address
from cdk-nag.
I've got this one happening too - it looks like the same issue is impacting on the OpenSearch Service domains only grant access via allowlisted IP addresses
rule as it checks the access properties attribute as well.
from cdk-nag.
this should be resolved in version 2.22.16
from cdk-nag.
Do you mind sharing the CloudFormation generated for this resource?
from cdk-nag.
sure, here is the cfn.template.json.
{
"Resources": {
"SecurityGroupDD263621": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "OpensearchStack/SecurityGroup",
"GroupName": "OSTestDev",
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow all outbound traffic by default",
"IpProtocol": "-1"
}
],
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
],
"VpcId": "vpc-xxxxxxxxxx"
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/SecurityGroup/Resource"
}
},
"SecurityGroupfromOpensearchStackSecurityGroupB321588E9200B5113157": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"IpProtocol": "tcp",
"Description": "Allow access for internal",
"FromPort": 9200,
"GroupId": {
"Fn::GetAtt": ["SecurityGroupDD263621", "GroupId"]
},
"SourceSecurityGroupId": {
"Fn::GetAtt": ["SecurityGroupDD263621", "GroupId"]
},
"ToPort": 9200
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/SecurityGroup/from OpensearchStackSecurityGroupB321588E:9200"
}
},
"FeaturestoreMasterUserA7B5B10F": {
"Type": "AWS::SecretsManager::Secret",
"Properties": {
"GenerateSecretString": {
"ExcludeCharacters": "{}'\\*[]()`",
"GenerateStringKey": "password",
"SecretStringTemplate": "{\"username\":\"admin\"}"
},
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
]
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/MasterUser/Resource"
}
},
"FeaturestoreSlowSearchLogs52AF2A0E": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"RetentionInDays": 30,
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
]
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/SlowSearchLogs/Resource"
}
},
"FeaturestoreAppLogs614CF09F": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"RetentionInDays": 30,
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
]
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/AppLogs/Resource"
}
},
"FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf337A22103": {
"Type": "Custom::CloudwatchLogResourcePolicy",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": ["AWS679f53fac002430cb0da5b7982bd22872D164C4C", "Arn"]
},
"Create": {
"Fn::Join": [
"",
[
"{\"service\":\"CloudWatchLogs\",\"action\":\"putResourcePolicy\",\"parameters\":{\"policyName\":\"ESLogPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3\",\"policyDocument\":\"{\\\"Statement\\\":[{\\\"Action\\\":[\\\"logs:PutLogEvents\\\",\\\"logs:CreateLogStream\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"Service\\\":\\\"es.amazonaws.com\\\"},\\\"Resource\\\":[\\\"",
{
"Fn::GetAtt": ["FeaturestoreSlowSearchLogs52AF2A0E", "Arn"]
},
"\\\",\\\"",
{
"Fn::GetAtt": ["FeaturestoreAppLogs614CF09F", "Arn"]
},
"\\\"]}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"physicalResourceId\":{\"id\":\"ESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3\"}}"
]
]
},
"Update": {
"Fn::Join": [
"",
[
"{\"service\":\"CloudWatchLogs\",\"action\":\"putResourcePolicy\",\"parameters\":{\"policyName\":\"ESLogPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3\",\"policyDocument\":\"{\\\"Statement\\\":[{\\\"Action\\\":[\\\"logs:PutLogEvents\\\",\\\"logs:CreateLogStream\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"Service\\\":\\\"es.amazonaws.com\\\"},\\\"Resource\\\":[\\\"",
{
"Fn::GetAtt": ["FeaturestoreSlowSearchLogs52AF2A0E", "Arn"]
},
"\\\",\\\"",
{
"Fn::GetAtt": ["FeaturestoreAppLogs614CF09F", "Arn"]
},
"\\\"]}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"physicalResourceId\":{\"id\":\"ESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3\"}}"
]
]
},
"Delete": "{\"service\":\"CloudWatchLogs\",\"action\":\"deleteResourcePolicy\",\"parameters\":{\"policyName\":\"ESLogPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3\"},\"ignoreErrorCodesMatching\":\"ResourceNotFoundException\"}",
"InstallLatestAwsSdk": false
},
"DependsOn": [
"FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3CustomResourcePolicyF2686B04"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/ESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3/Resource/Default"
}
},
"FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3CustomResourcePolicyF2686B04": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": ["logs:DeleteResourcePolicy", "logs:PutResourcePolicy"],
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3CustomResourcePolicyF2686B04",
"Roles": [
{
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
]
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/ESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3/CustomResourcePolicy/Resource"
}
},
"FeaturestoreC553BC80": {
"Type": "AWS::OpenSearchService::Domain",
"Properties": {
"AdvancedSecurityOptions": {
"Enabled": true,
"InternalUserDatabaseEnabled": true,
"MasterUserOptions": {
"MasterUserName": "admin",
"MasterUserPassword": {
"Fn::Join": [
"",
[
"{{resolve:secretsmanager:",
{
"Ref": "FeaturestoreMasterUserA7B5B10F"
},
":SecretString:password::}}"
]
]
}
}
},
"ClusterConfig": {
"DedicatedMasterEnabled": false,
"InstanceCount": 1,
"InstanceType": "r6g.large.search",
"ZoneAwarenessEnabled": false
},
"DomainEndpointOptions": {
"EnforceHTTPS": true,
"TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07"
},
"DomainName": "ostestdev-feature-store",
"EBSOptions": {
"EBSEnabled": true,
"VolumeSize": 128,
"VolumeType": "gp2"
},
"EncryptionAtRestOptions": {
"Enabled": true
},
"EngineVersion": "OpenSearch_2.3",
"LogPublishingOptions": {
"ES_APPLICATION_LOGS": {
"CloudWatchLogsLogGroupArn": {
"Fn::GetAtt": ["FeaturestoreAppLogs614CF09F", "Arn"]
},
"Enabled": true
},
"SEARCH_SLOW_LOGS": {
"CloudWatchLogsLogGroupArn": {
"Fn::GetAtt": ["FeaturestoreSlowSearchLogs52AF2A0E", "Arn"]
},
"Enabled": true
}
},
"NodeToNodeEncryptionOptions": {
"Enabled": true
},
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
],
"VPCOptions": {
"SecurityGroupIds": [
{
"Fn::GetAtt": ["SecurityGroupDD263621", "GroupId"]
}
],
"SubnetIds": ["subnet-061347620c70f94cd"]
}
},
"DependsOn": [
"FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf3CustomResourcePolicyF2686B04",
"FeaturestoreESLogGroupPolicyc8ae71755b6a4e8535be6d7a7fcf8050f03e7febf337A22103"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/Resource",
"cdk_nag": {
"rules_to_suppress": [
{
"reason": "OpenSearch is not publicly accessible",
"id": "AwsSolutions-OS5"
}
]
}
}
},
"FeaturestoreAccessPolicyBAB12452": {
"Type": "Custom::OpenSearchAccessPolicy",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": ["AWS679f53fac002430cb0da5b7982bd22872D164C4C", "Arn"]
},
"Create": {
"Fn::Join": [
"",
[
"{\"action\":\"updateDomainConfig\",\"service\":\"OpenSearch\",\"parameters\":{\"DomainName\":\"",
{
"Ref": "FeaturestoreC553BC80"
},
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":[\\\"es:ESHttpGet\\\",\\\"es:ESHttpPut\\\",\\\"es:ESHttpPost\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"arn:",
{
"Ref": "AWS::Partition"
},
":iam::",
{
"Ref": "AWS::AccountId"
},
":root\\\"},\\\"Resource\\\":\\\"*\\\"},{\\\"Action\\\":[\\\"logs:PutLogEvents\\\",\\\"logs:CreateLogStream\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"Service\\\":\\\"es.amazonaws.com\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPaths\":[\"DomainConfig.AccessPolicies\"],\"physicalResourceId\":{\"id\":\"",
{
"Ref": "FeaturestoreC553BC80"
},
"AccessPolicy\"}}"
]
]
},
"Update": {
"Fn::Join": [
"",
[
"{\"action\":\"updateDomainConfig\",\"service\":\"OpenSearch\",\"parameters\":{\"DomainName\":\"",
{
"Ref": "FeaturestoreC553BC80"
},
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":[\\\"es:ESHttpGet\\\",\\\"es:ESHttpPut\\\",\\\"es:ESHttpPost\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"arn:",
{
"Ref": "AWS::Partition"
},
":iam::",
{
"Ref": "AWS::AccountId"
},
":root\\\"},\\\"Resource\\\":\\\"*\\\"},{\\\"Action\\\":[\\\"logs:PutLogEvents\\\",\\\"logs:CreateLogStream\\\"],\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"Service\\\":\\\"es.amazonaws.com\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPaths\":[\"DomainConfig.AccessPolicies\"],\"physicalResourceId\":{\"id\":\"",
{
"Ref": "FeaturestoreC553BC80"
},
"AccessPolicy\"}}"
]
]
},
"InstallLatestAwsSdk": false
},
"DependsOn": ["FeaturestoreAccessPolicyCustomResourcePolicy28188FE6"],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/AccessPolicy/Resource/Default"
}
},
"FeaturestoreAccessPolicyCustomResourcePolicy28188FE6": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "es:UpdateDomainConfig",
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": ["FeaturestoreC553BC80", "Arn"]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "FeaturestoreAccessPolicyCustomResourcePolicy28188FE6",
"Roles": [
{
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
]
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/Featurestore/AccessPolicy/CustomResourcePolicy/Resource"
}
},
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
],
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
]
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/AWS679f53fac002430cb0da5b7982bd2287/ServiceRole/Resource"
}
},
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "400f664767ec04a0966c8d688fa643ee8f6d0c94c8d91a71d3af814cc9b9e6ab.zip"
},
"Role": {
"Fn::GetAtt": [
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": "nodejs14.x",
"Tags": [
{
"Key": "namespace",
"Value": "OSTestDev"
},
{
"Key": "stage",
"Value": "Dev"
}
],
"Timeout": 120
},
"DependsOn": ["AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"],
"Metadata": {
"aws:cdk:path": "OpensearchStack/AWS679f53fac002430cb0da5b7982bd2287/Resource",
"aws:asset:path": "asset.400f664767ec04a0966c8d688fa643ee8f6d0c94c8d91a71d3af814cc9b9e6ab",
"aws:asset:is-bundled": false,
"aws:asset:property": "Code"
}
},
"CDKMetadata": {
"Type": "AWS::CDK::Metadata",
"Properties": {
"Analytics": "v2:deflate64:H4sIAAAAAAAA/32Qz2rDMAzGn6V3xyMplF3XjJXBDiN7gOA6WuYmtoplt5SQd5+cf4cddtLv0ydLHy7kYS+LnbpTppsu681ZDl9B6U5wqx5AF6xBR2/C4+QxXkX57f5vvLvWA9Eo8AqOQHn9Q+BvRoMcXtEq49KTmUZBoD0EssqpFvx0jPWylGkUPbYkhw9st3Mrs6fsuVH8yri2h4DuLTodDDqxAc+vPAqjrBw+sTf6kYyFKuwhyVQ50b5WRJxJvqTCWh6j7iAcFbFdAWH0GoSOFNDWftE8fqdy6m0jfyWfWHnazT/dcvJklOgaM4d02IC80NMtP8j8Wea7CxmT+eiCsSCruf4CmltOobkBAAA="
},
"Metadata": {
"aws:cdk:path": "OpensearchStack/CDKMetadata/Default"
},
"Condition": "CDKMetadataAvailable"
}
},
"Conditions": {
"CDKMetadataAvailable": {
"Fn::Or": [
{
"Fn::Or": [
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"af-south-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-east-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-northeast-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-northeast-2"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-south-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-southeast-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ap-southeast-2"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"ca-central-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"cn-north-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"cn-northwest-1"
]
}
]
},
{
"Fn::Or": [
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-central-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-north-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-south-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-west-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-west-2"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"eu-west-3"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"me-south-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"sa-east-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"us-east-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"us-east-2"
]
}
]
},
{
"Fn::Or": [
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"us-west-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"us-west-2"
]
}
]
}
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
["1", "2", "3", "4", "5"],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
from cdk-nag.
Related Issues (20)
- doc: AwsSolutions-CFR6 conflicts with AWS recommendation HOT 5
- bug: CodeBuildProjectSourceRepoUrl is out of date HOT 1
- feat: Test Utils as part of the library HOT 3
- Usage in pre-commit checks that only flag for brand new resources HOT 5
- bug: HIPAA.Security-RDSInBackupPlan not recognizing Serverless Postgres Cluster Instances HOT 1
- bug: SQS used as a DLQ on a lambda produces AwsSolutions-SQS3 HOT 1
- bug: ApplicationLoadBalancedFargateService not correctly detecting certificate with redirectHTTP HOT 1
- bug: CFN Resources go unchecked HOT 1
- feat: CIS Checks HOT 1
- feat: discourage use of DesiredCount for auto-scaled ECS services HOT 1
- AwsSolutions-SF1 conflicts with AWS recommendations HOT 2
- Do NagSuppressions have to be applied inside Stack constructor only? HOT 1
- feat: Serverless Nag Pack
- feat: Support for AWS Resource Tagging Standards HOT 2
- bug: AwsSolutions-L1 issue with Python runtime 3.12 HOT 1
- CloudFrontDistributionNoOutdatedSSL: Does not allow for s3 static hosting via cloudfront HOT 1
- Exported rules aren't typed correctly HOT 2
- feat: Simpler appliesTo syntax for referencing CDK nodes HOT 1
- bug: CDK Stages not linted by Nag rules HOT 4
- feat: Support PCI DSS 4.0 Rules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdk-nag.