# Create the permissions policy
cat > neuraltrust-dataplane-policy.json << EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VPCInfrastructure",
"Effect": "Allow",
"Action": [
"ec2:CreateVpc",
"ec2:CreateSubnet",
"ec2:CreateSecurityGroup",
"ec2:CreateRouteTable",
"ec2:CreateRoute",
"ec2:CreateInternetGateway",
"ec2:CreateNatGateway",
"ec2:AttachInternetGateway",
"ec2:AssociateRouteTable",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress",
"ec2:AllocateAddress",
"ec2:CreateTags",
"ec2:Describe*",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:ModifyLoadBalancerAttributes",
"elasticloadbalancing:ModifyTargetGroupAttributes",
"elasticloadbalancing:RegisterTargets",
"elasticloadbalancing:AddTags",
"elasticloadbalancing:Describe*"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestedRegion": "YOUR-CHOSEN-REGION"
}
}
},
{
"Sid": "KubernetesCluster",
"Effect": "Allow",
"Action": [
"eks:CreateCluster",
"eks:CreateNodegroup",
"eks:UpdateClusterConfig",
"eks:UpdateNodegroupConfig",
"eks:TagResource",
"eks:Describe*",
"eks:List*",
"ec2:RunInstances",
"ec2:TerminateInstances",
"autoscaling:CreateAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:CreateLaunchTemplate",
"autoscaling:CreateOrUpdateTags",
"autoscaling:Describe*"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestedRegion": "YOUR-CHOSEN-REGION"
}
}
},
{
"Sid": "IAMForEKS",
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:AttachRolePolicy",
"iam:CreateInstanceProfile",
"iam:AddRoleToInstanceProfile",
"iam:PassRole",
"iam:GetRole",
"iam:ListAttachedRolePolicies"
],
"Resource": [
"arn:aws:iam::*:role/neuraltrust-*",
"arn:aws:iam::*:instance-profile/neuraltrust-*"
]
},
{
"Sid": "S3BucketCreation",
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:PutBucketEncryption",
"s3:PutBucketVersioning",
"s3:PutBucketPolicy",
"s3:PutBucketTagging",
"s3:GetBucket*",
"s3:ListBucket*"
],
"Resource": "arn:aws:s3:::neuraltrust-*"
},
{
"Sid": "S3ObjectAccess",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:GetObjectVersion",
"s3:PutObjectTagging"
],
"Resource": "arn:aws:s3:::neuraltrust-*/*"
},
{
"Sid": "KMSKeyCreation",
"Effect": "Allow",
"Action": [
"kms:CreateKey",
"kms:CreateAlias",
"kms:PutKeyPolicy",
"kms:TagResource",
"kms:DescribeKey",
"kms:GetKeyPolicy",
"kms:ListKeys",
"kms:ListAliases"
],
"Resource": "*",
"Condition": {
"StringLike": {
"kms:AliasName": "alias/neuraltrust-*"
}
}
},
{
"Sid": "KMSKeyUsage",
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*",
"Condition": {
"StringLike": {
"kms:AliasName": "alias/neuraltrust-*"
}
}
},
{
"Sid": "SecretsManager",
"Effect": "Allow",
"Action": [
"secretsmanager:CreateSecret",
"secretsmanager:UpdateSecret",
"secretsmanager:GetSecretValue",
"secretsmanager:TagResource"
],
"Resource": "arn:aws:secretsmanager:*:*:secret:neuraltrust/*"
},
{
"Sid": "MonitoringAndLogging",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData",
"cloudwatch:CreateLogGroup",
"cloudwatch:CreateLogStream",
"cloudwatch:PutLogEvents",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLog*"
],
"Resource": [
"arn:aws:cloudwatch:*:*:*",
"arn:aws:logs:*:*:log-group:/neuraltrust/*"
]
}
]
}
EOF
# Create and attach the policy
aws iam create-policy \
--policy-name NeuralTrustDataPlanePolicy \
--policy-document file://neuraltrust-dataplane-policy.json
aws iam attach-user-policy \
--user-name NeuralTrustDataPlaneUser \
--policy-arn arn:aws:iam::YOUR-ACCOUNT-ID:policy/NeuralTrustDataPlanePolicy