Skip to content
GitHubXDiscord

GeoMatchSet

The GeoMatchSet resource allows you to manage AWS WAFRegional GeoMatchSets that specify the countries from which you want to allow or block incoming web requests.

Create a basic GeoMatchSet with a name and a country constraint.

import AWS from "alchemy/aws/control";
const geoMatchSet = await AWS.WAFRegional.GeoMatchSet("basicGeoMatchSet", {
Name: "BasicGeoMatchSet",
GeoMatchConstraints: [
{
Type: "Country",
Value: "US"
},
{
Type: "Country",
Value: "CA"
}
],
adopt: true // Adopt existing resource if it already exists
});

Configure a GeoMatchSet with multiple geographic constraints.

const advancedGeoMatchSet = await AWS.WAFRegional.GeoMatchSet("advancedGeoMatchSet", {
Name: "AdvancedGeoMatchSet",
GeoMatchConstraints: [
{
Type: "Country",
Value: "FR"
},
{
Type: "Country",
Value: "GB"
},
{
Type: "Country",
Value: "DE"
}
]
});

Update an existing GeoMatchSet to add an additional country constraint.

const updatedGeoMatchSet = await AWS.WAFRegional.GeoMatchSet("updatedGeoMatchSet", {
Name: "AdvancedGeoMatchSet",
GeoMatchConstraints: [
{
Type: "Country",
Value: "FR"
},
{
Type: "Country",
Value: "GB"
},
{
Type: "Country",
Value: "DE"
},
{
Type: "Country",
Value: "JP"
}
]
});

Remove a GeoMatchSet when it is no longer needed.

await AWS.WAFRegional.GeoMatchSet("deleteGeoMatchSet", {
Name: "BasicGeoMatchSet",
adopt: false // Do not adopt existing resource
});