微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何解决 AWS Bad String 上的 JSON 错误?

如何解决如何解决 AWS Bad String 上的 JSON 错误?

不知道这里的坏字符串在哪里,有人可以帮助我吗? 它在 AWS 控制台上看起来像是一条错误错误消息,但我在此处找不到我遗漏的内容

此脚本用于创建 VPC、路由、IGW 和 Palo Alto 防火墙,认为问题出在我遗漏的某些 ] 或 }。

我们是否有分析它的工具,而不是手动搜索

var content = new ByteArrayContent(await ToByteArray(request.Body));

解决方法

是的,您遗漏了 } 和一些额外的 ,。下面是有效的 json。模板可能有其他问题,但您当前的错误是关于无效的 json,所以我只修复了这个问题。对于新问题,请提出新问题。

{
    "AWSTemplateFormatVersion": "2010-09-09","Description": "PANW Firewall (sample-cft).","Parameters": {
        "BootstrapBucketName": {
            "Description": "Bucket name for FW bootstrap configuration","Type": "String"
        },"ServerKeyName": {
            "Description": "Name of an existing EC2 KeyPair to enable SSH access to the FW (Hint: You MUST have its private key)","Type": "AWS::EC2::KeyPair::KeyName"
        }
    },"Mappings": {
        "PANFWRegionMap": {
            "us-west-2": {
                "AMI": "ami-d28992ab"
            },"ap-northeast-1": {
                "AMI": "ami-ab04e7cd"
            },"us-west-1": {
                "AMI": "ami-0f88a16f"
            },"ap-northeast-2": {
                "AMI": "ami-6cbd6402"
            },"ap-southeast-1": {
                "AMI": "ami-1897057b"
            },"ap-southeast-2": {
                "AMI": "ami-8ed3cced"
            },"eu-central-1": {
                "AMI": "ami-6df35f02"
            },"eu-west-1": {
                "AMI": "ami-86d63eff"
            },"eu-west-2": {
                "AMI": "ami-3c170658"
            },"sa-east-1": {
                "AMI": "ami-15651279"
            },"us-east-1": {
                "AMI": "ami-0d7ef242edccdad95"
            },"us-east-2": {
                "AMI": "ami-f1200094"
            },"ca-central-1": {
                "AMI": "ami-0f08b76b"
            },"ap-south-1": {
                "AMI": "ami-1ffc8470"
            }
        }
    },"Resources": {
        "BootstrapRole": {
            "Type": "AWS::IAM::Role","Properties": {
                "AssumeRolePolicyDocument": {
                    "Version": "2012-10-17","Statement": [{
                        "Effect": "Allow","Principal": {
                            "Service": "ec2.amazonaws.com"
                        },"Action": "sts:AssumeRole"
                    }]
                },"Path": "/","Policies": [{
                    "PolicyName": "BootstrapRolePolicy","PolicyDocument": {
                        "Version": "2012-10-17","Statement": [{
                                "Effect": "Allow","Action": "s3:ListBucket","Resource": {
                                    "Fn::Join": ["",["arn:aws:s3:::",{
                                        "Ref": "BootstrapBucketName"
                                    }]]
                                }
                            },{
                                "Effect": "Allow","Action": "s3:GetObject",{
                                        "Ref": "BootstrapBucketName"
                                    },"/*"]]
                                }
                            }
                        ]
                    }
                }]
            }
        },"BootstrapInstanceProfile": {
            "Type": "AWS::IAM::InstanceProfile","Properties": {
                "Path": "/","Roles": [{
                    "Ref": "BootstrapRole"
                }]
            }
        },"NewVPC": {
            "Type": "AWS::EC2::VPC","Properties": {
                "CidrBlock": "10.0.0.0/16","InstanceTenancy": "default","EnableDnsSupport": "true","EnableDnsHostnames": "true","Tags": [{
                    "Key": "Name","Value": "PAN Sample CFT"
                }]
            }
        },"PublicElasticIP": {
            "Type": "AWS::EC2::EIP","Properties": {
                "Domain": "vpc"
            },"DependsOn": ["NewVPC"]
        },"ManagementElasticIP": {
            "Type": "AWS::EC2::EIP","NewDBSubnet": {
            "Type": "AWS::EC2::Subnet","Properties": {
                "CidrBlock": "10.0.2.0/24","VpcId": {
                    "Ref": "NewVPC"
                },"AvailabilityZone": "","Value": "PAN Sample CFT"
                }]
            },"DependsOn": "NewVPC"
        },"NewPublicSubnet": {
            "Type": "AWS::EC2::Subnet","Properties": {
                "CidrBlock": "10.0.0.0/24","AvailabilityZone": {
                    "Fn::GetAtt": ["NewDBSubnet","AvailabilityZone"]
                },"DependsOn": ["NewVPC","NewDBSubnet"]
        },"NewWebSubnet": {
            "Type": "AWS::EC2::Subnet","Properties": {
                "CidrBlock": "10.0.1.0/24","igweb3def8e": {
            "Type": "AWS::EC2::InternetGateway","Properties": {
                "Tags": [{
                    "Key": "Name","dopt21c7d043": {
            "Type": "AWS::EC2::DHCPOptions","Properties": {
                "DomainName": "us-west-2.compute.internal","DomainNameServers": [
                    "AmazonProvidedDNS"
                ]
            }
        },"aclb765d6d2": {
            "Type": "AWS::EC2::NetworkAcl","Properties": {
                "VpcId": {
                    "Ref": "NewVPC"
                }
            }
        },"rtb059a2460": {
            "Type": "AWS::EC2::RouteTable","rtb049a2461": {
            "Type": "AWS::EC2::RouteTable","FWManagementNetworkInterface": {
            "Type": "AWS::EC2::NetworkInterface","Properties": {
                "Description": "AWS FW1 MGMT","SubnetId": {
                    "Ref": "NewPublicSubnet"
                },"SourceDestCheck": "false","PrivateIpAddresses": [{
                    "PrivateIpAddress": "10.0.0.99","Primary": "true"
                }],"GroupSet": [{
                    "Ref": "sgWideOpen"
                }],"Value": "WP AWS FW1 MGMT"
                }]
            },"DependsOn": ["sgWideOpen"]
        },"FWPublicNetworkInterface": {
            "Type": "AWS::EC2::NetworkInterface","Properties": {
                "Description": "AWS FW1 E1/1","PrivateIpAddresses": [{
                    "PrivateIpAddress": "10.0.0.100","Value": "WP AWS FW1 E1/1"
                }]
            },"FWPrivate12NetworkInterface": {
            "Type": "AWS::EC2::NetworkInterface","Properties": {
                "Description": "AWS FW1 E1/2","SubnetId": {
                    "Ref": "NewWebSubnet"
                },"PrivateIpAddresses": [{
                    "PrivateIpAddress": "10.0.1.11","Value": "WP AWS FW1 E1/2"
                }]
            },"FWPrivate13NetworkInterface": {
            "Type": "AWS::EC2::NetworkInterface","Properties": {
                "Description": "AWS FW1 E1/3","SubnetId": {
                    "Ref": "NewDBSubnet"
                },"PrivateIpAddresses": [{
                    "PrivateIpAddress": "10.0.2.11","Value": "WP AWS FW1 E1/3"
                }]
            },"FWEIPMAnagementAssociation": {
            "Type": "AWS::EC2::EIPAssociation","Properties": {
                "AllocationId": {
                    "Fn::GetAtt": ["ManagementElasticIP","AllocationId"]
                },"NetworkInterfaceId": {
                    "Ref": "FWManagementNetworkInterface"
                }
            },"DependsOn": ["FWManagementNetworkInterface","ManagementElasticIP"]
        },"FWEIPPublicAssociation": {
            "Type": "AWS::EC2::EIPAssociation","Properties": {
                "AllocationId": {
                    "Fn::GetAtt": ["PublicElasticIP","NetworkInterfaceId": {
                    "Ref": "FWPublicNetworkInterface"
                }
            },"DependsOn": ["FWPublicNetworkInterface","PublicElasticIP"]
        },"sgWideOpen": {
            "Type": "AWS::EC2::SecurityGroup","Properties": {
                "GroupDescription": "Wide open security group","Value": "Lab External SG"
                }],"SecurityGroupIngress": [{
                    "IpProtocol": "-1","CidrIp": "0.0.0.0/0"
                }],"SecurityGroupEgress": [{
                    "IpProtocol": "-1","CidrIp": "0.0.0.0/0"
                }]
            }
        },"acl1": {
            "Type": "AWS::EC2::NetworkAclEntry","Properties": {
                "CidrBlock": "0.0.0.0/0","Egress": "true","Protocol": "-1","RuleAction": "allow","RuleNumber": "100","NetworkAclId": {
                    "Ref": "aclb765d6d2"
                }
            }
        },"acl2": {
            "Type": "AWS::EC2::NetworkAclEntry","subnetacl1": {
            "Type": "AWS::EC2::SubnetNetworkAclAssociation","Properties": {
                "NetworkAclId": {
                    "Ref": "aclb765d6d2"
                },"SubnetId": {
                    "Ref": "NewDBSubnet"
                }
            }
        },"subnetacl2": {
            "Type": "AWS::EC2::SubnetNetworkAclAssociation","SubnetId": {
                    "Ref": "NewPublicSubnet"
                }
            }
        },"subnetacl3": {
            "Type": "AWS::EC2::SubnetNetworkAclAssociation","SubnetId": {
                    "Ref": "NewWebSubnet"
                }
            }
        },"gw1": {
            "Type": "AWS::EC2::VPCGatewayAttachment","Properties": {
                "VpcId": {
                    "Ref": "NewVPC"
                },"InternetGatewayId": {
                    "Ref": "igweb3def8e"
                }
            }
        },"subnetroute2": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation","Properties": {
                "RouteTableId": {
                    "Ref": "rtb049a2461"
                },"route1": {
            "Type": "AWS::EC2::Route","Properties": {
                "DestinationCidrBlock": "0.0.0.0/0","RouteTableId": {
                    "Ref": "rtb059a2460"
                },"GatewayId": {
                    "Ref": "igweb3def8e"
                }
            },"DependsOn": "gw1"
        },"route2": {
            "Type": "AWS::EC2::Route","RouteTableId": {
                    "Ref": "rtb049a2461"
                },"dchpassoc1": {
            "Type": "AWS::EC2::VPCDHCPOptionsAssociation","DhcpOptionsId": {
                    "Ref": "dopt21c7d043"
                }
            }
        },"FWInstance": {
            "Type": "AWS::EC2::Instance","Properties": {
                "DisableApiTermination": "false","IamInstanceProfile": {
                    "Ref": "BootstrapInstanceProfile"
                },"InstanceInitiatedShutdownBehavior": "stop","EbsOptimized": "true","ImageId": {
                    "Fn::FindInMap": ["PANFWRegionMap",{
                        "Ref": "AWS::Region"
                    },"AMI"]
                },"InstanceType": "m4.xlarge","BlockDeviceMappings": [{
                    "DeviceName": "/dev/xvda","Ebs": {
                        "VolumeType": "gp2","DeleteOnTermination": "true","VolumeSize": "60"
                    }
                }],"KeyName": {
                    "Ref": "ServerKeyName"
                },"Monitoring": "false","Value": "WP VM-Series Firewall"
                }],"NetworkInterfaces": [{
                        "NetworkInterfaceId": {
                            "Ref": "FWManagementNetworkInterface"
                        },"DeviceIndex": 0
                    },{
                        "NetworkInterfaceId": {
                            "Ref": "FWPublicNetworkInterface"
                        },"DeviceIndex": 1
                    },{
                        "NetworkInterfaceId": {
                            "Ref": "FWPrivate12NetworkInterface"
                        },"DeviceIndex": 2
                    },{
                        "NetworkInterfaceId": {
                            "Ref": "FWPrivate13NetworkInterface"
                        },"DeviceIndex": 3
                    }
                ],"UserData": {
                    "Fn::Base64": {
                        "Fn::Join": ["",[
                            "vmseries-bootstrap-aws-s3bucket=",{
                                "Ref": "BootstrapBucketName"
                            }
                        ]]
                    }
                }
            },"FWPrivate12NetworkInterface","FWPrivate13NetworkInterface","NewPublicSubnet"]
        },"Outputs": {
            "FirewallManagementURL": {
                "Description": "VM-Series management interface URL","Value": {
                    "Fn::Join": ["",[
                        "https://",{
                            "Ref": "ManagementElasticIP"
                        }
                    ]]
                }
            }
        }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。