-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
cloudrunv2-disallow-public-ingress
policy
- Loading branch information
Showing
9 changed files
with
67 additions
and
7 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 |
---|---|---|
@@ -1 +1 @@ | ||
export * as cloudRunService from "./cloudrunService" | ||
export * as cloudrunService from "./cloudrunService" |
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,30 @@ | ||
import * as gcp from "@pulumi/gcp"; | ||
|
||
export const clodrunv2ServicePass1 = new gcp.cloudrunv2.Service("pass#1", { | ||
location: "europe-west1", | ||
template: { | ||
containers: [{ | ||
image: "us-docker.pkg.dev/cloudrun/container/hello", | ||
}], | ||
}, | ||
}); | ||
|
||
export const clodrunv2ServicePass2 = new gcp.cloudrunv2.Service("pass#2", { | ||
location: "europe-west1", | ||
ingress: "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER", | ||
template: { | ||
containers: [{ | ||
image: "us-docker.pkg.dev/cloudrun/container/hello", | ||
}], | ||
}, | ||
}); | ||
|
||
export const clodrunv2ServiceFail1 = new gcp.cloudrunv2.Service("fail#1", { | ||
location: "europe-west1", | ||
ingress: "INGRESS_TRAFFIC_ALL", | ||
template: { | ||
containers: [{ | ||
image: "us-docker.pkg.dev/cloudrun/container/hello", | ||
}], | ||
}, | ||
}); |
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 @@ | ||
export * as cloudrunV2Service from "../cloudrunv2/cloudrunv2Service" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * as cloudRun from './cloudrun/index' | ||
export * as cloudrun from './cloudrun/index' | ||
export * as cloudrunv2 from './cloudrunv2/index' | ||
export * as compute from './compute/index' |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { cloudrunDisallowPublicIngress } from "./cloudrunDisallowPublicIngress"; | ||
|
||
export const cloudRunPolicies = [ | ||
export const cloudrunPolicies = [ | ||
cloudrunDisallowPublicIngress, | ||
]; |
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,17 @@ | ||
import { ResourceValidationArgs, ReportViolation, EnforcementLevel } from "@pulumi/policy"; | ||
|
||
export const cloudrunv2DisallowPublicIngress = { | ||
name: "cloudrunv2-disallow-public-ingress", | ||
description: "Check that CloudRun2 services do not have public ingress set to 'all'.", | ||
enforcementLevel: "advisory" as EnforcementLevel, | ||
validateResource: (args: ResourceValidationArgs, reportViolation: ReportViolation) => { | ||
if (args.type === "gcp:cloudrunv2/service:Service") { | ||
const ingress = args.props.ingress; | ||
if (ingress && ingress === "INGRESS_TRAFFIC_ALL") { | ||
reportViolation( | ||
"CloudRun2 services should not have public ingress set to 'all'. Use a load balancer instead." | ||
); | ||
} | ||
} | ||
}, | ||
} |
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,5 @@ | ||
import { cloudrunv2DisallowPublicIngress } from "./cloudrunv2DisallowPublicIngress"; | ||
|
||
export const cloudrunv2Policies = [ | ||
cloudrunv2DisallowPublicIngress, | ||
]; |
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