วิธีแก้ไข ResourceErrorCode: 400 เมื่อปรับใช้ทรัพยากรไฟร์วอลล์ด้วย Google Cloud Deployment Manager
ฉันกำลังพยายามปรับใช้ทรัพยากรไฟร์วอลล์เดียวกับ Google Cloud Deployment Manager ฉันต้องการให้ไฟร์วอลล์บล็อกเฉพาะที่อยู่ IP ของฉันเองไม่ให้เข้าถึงแอป App Engine ของฉันที่ใช้งานแล้วที่https://cloudfunctiongateway.uc.r.appspot.com/. อย่างไรก็ตามฉันได้รับข้อผิดพลาด:
location: /deployments/firewall-deployment2/resources/app-firewall
message: '{"ResourceType":"compute.v1.firewall","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"Request
contains an invalid argument.","status":"INVALID_ARGUMENT","statusMessage":"Bad
Request","requestPath":"https://compute.googleapis.com/compute/v1/projects/cloudfunctiongateway/global/firewalls","httpMethod":"POST"}}'
นี่คือไฟล์กำหนดค่าของฉันในfirewall.yaml
:
resources:
- type: compute.v1.firewall
name: app-firewall
properties:
network: https://cloudfunctiongateway.uc.r.appspot.com/
denied:
- IPProtocol: 33.27.10.123 # a fake ip address, I use my real one
sourceRanges: [ 0.0.0.0/0 ]
และฉันกำลังเรียกใช้คำสั่งนี้ในไดเร็กทอรีเดียวกัน:
gcloud deployment-manager deployments create firewall-deployment --config firewall.yaml
ฉันได้พยายามปรับใช้ด้วยสิ่งนี้ในไฟล์กำหนดค่าของฉัน:
resources:
- type: compute.v1.firewall
name: app-firewall
แต่ยังคงได้รับข้อความแสดงข้อผิดพลาดเดียวกัน วิธีใดในการแก้ไขปัญหานี้ หมายเหตุฉันต้องการดำเนินการนี้ด้วย Deployment Manager ฉันรู้อยู่แล้วว่าสามารถตั้งค่าไฟร์วอลล์ได้ด้วยตนเองจาก App Engine Dashboard
คำตอบ
สิ่งที่คุณต้องการจริงๆคือสร้างกฎไฟร์วอลล์สำหรับแอปพลิเคชันApp Engineซึ่งเป็นสิ่งที่แตกต่างจากไฟร์วอลล์ GCP ซึ่งเป็นสองสิ่งที่แตกต่างกัน
ดังนั้น - ในการดำเนินการนี้ให้ลองรันสิ่งนี้:
resources:
- name: dmapprule1
type: gcp-types/appengine-v1:apps.firewall.ingressRules
properties:
appsId: 00c61b117c74f1a3bbcb4900df618a4c4ae211790ade0822a63cb492d671f318776a5a
priority: 1000
action: "DENY"
source_range: "0.0.0.0/0"
และเรียกใช้ด้วย gcloud deployment-manager deployments create firewall-deployment --config firewall.yaml
อัปเดต
หากต้องการดูรายการประเภทที่รองรับทั้งหมดให้ใช้gcloud beta deployment-manager types list
(รายการเวอร์ชันเบต้าครอบคลุมกว่ามาก)