Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(provider-generator): Skip statement block for rule block in aws_wafv2_web_acl and aws_wafv2_rule_group resources #3414

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/typescript/aws-cloudfront-proxy/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ class MyStack extends TerraformStack {
sampledRequestsEnabled: true,
},
statement: {
managedRuleGroupStatement: {
managed_rule_group_statement: {
name: "managed-rule-example",
vendorName: "AWS",
excludedRule: [
vendor_name: "AWS",
excluded_rule: [
{
name: "SizeRestrictions_QUERYSTRING",
},
{ name: "SQLInjection_QUERYSTRING" },
],
scopeDownStatement: {
geoMatchStatement: {
countryCodes: ["US"],
scope_down_statement: {
geo_match_statement: {
country_codes: ["US"],
},
},
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,30 @@ test("shard exports across multiple files to avoid generating files with more th
await code.save(workdir);

const output = fs.readFileSync(
path.join(workdir, "providers/aws/wafv2-web-acl/index.ts"),
path.join(workdir, "providers/test/wafv2-web-acl/index.ts"),
"utf-8"
);
expect(output).toMatchSnapshot(`wafv2-web-acl-resource`);

const outputStructsIndex = fs.readFileSync(
path.join(workdir, "providers/aws/wafv2-web-acl/index-structs/index.ts"),
path.join(workdir, "providers/test/wafv2-web-acl/index-structs/index.ts"),
"utf-8"
);
expect(outputStructsIndex).toMatchSnapshot(`structs-index`);

const outputStructs0 = fs.readFileSync(
path.join(workdir, "providers/aws/wafv2-web-acl/index-structs/structs0.ts"),
path.join(
workdir,
"providers/test/wafv2-web-acl/index-structs/structs0.ts"
),
"utf-8"
);
expect(outputStructs0).toMatchSnapshot(`structs0`);

const outputStructs400 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs400.ts"
"providers/test/wafv2-web-acl/index-structs/structs400.ts"
),
"utf-8"
);
Expand All @@ -54,7 +57,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs800 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs800.ts"
"providers/test/wafv2-web-acl/index-structs/structs800.ts"
),
"utf-8"
);
Expand All @@ -63,7 +66,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs1200 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs1200.ts"
"providers/test/wafv2-web-acl/index-structs/structs1200.ts"
),
"utf-8"
);
Expand All @@ -72,7 +75,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs1600 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs1600.ts"
"providers/test/wafv2-web-acl/index-structs/structs1600.ts"
),
"utf-8"
);
Expand All @@ -81,7 +84,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs2000 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs2000.ts"
"providers/test/wafv2-web-acl/index-structs/structs2000.ts"
),
"utf-8"
);
Expand All @@ -90,7 +93,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs2400 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs2400.ts"
"providers/test/wafv2-web-acl/index-structs/structs2400.ts"
),
"utf-8"
);
Expand All @@ -99,7 +102,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs2800 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs2800.ts"
"providers/test/wafv2-web-acl/index-structs/structs2800.ts"
),
"utf-8"
);
Expand All @@ -108,7 +111,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs3200 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs3200.ts"
"providers/test/wafv2-web-acl/index-structs/structs3200.ts"
),
"utf-8"
);
Expand All @@ -117,7 +120,7 @@ test("shard exports across multiple files to avoid generating files with more th
const outputStructs3600 = fs.readFileSync(
path.join(
workdir,
"providers/aws/wafv2-web-acl/index-structs/structs3600.ts"
"providers/test/wafv2-web-acl/index-structs/structs3600.ts"
),
"utf-8"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"provider_schemas": {
"registry.terraform.io/hashicorp/aws": {
"registry.terraform.io/hashicorp/test": {
"resource_schemas": {
"aws_wafv2_web_acl": {
"test_wafv2_web_acl": {
"version": 0,
"block": {
"attributes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const SKIPPED_ATTRIBUTES: string[] = [
"aws.quicksight_template.definition",
"aws.quicksight_dashboard.definition",
"aws.quicksight_analysis.definition",
"aws.wafv2_web_acl.wafv2_web_acl_rule.statement",
"aws.wafv2_rule_group.wafv2_rule_group_rule.statement",
];

/**
Expand Down
88 changes: 0 additions & 88 deletions test/typescript/synth-app/__snapshots__/test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,6 @@ output "instance-http-endpoint" {

output "tf-env-var-output" {
value = "no-value-found"
}
resource "aws_wafv2_web_acl" "wafv2" {
name = "managed-rule-example"
scope = "REGIONAL"
default_action {
allow {

}
}
rule {
name = "managed-rule-example"
priority = 1
override_action {
count {

}
}
statement {
managed_rule_group_statement {
name = "managed-rule-example"
vendor_name = "AWS"
excluded_rule {
name = "SizeRestrictions_QUERYSTRING"
}
excluded_rule {
name = "SQLInjection_QUERYSTRING"
}
}
}
visibility_config {
cloudwatch_metrics_enabled = true
metric_name = "managed-rule-example"
sampled_requests_enabled = true
}
}
visibility_config {
cloudwatch_metrics_enabled = true
metric_name = "managed-rule-example"
sampled_requests_enabled = true
}
}"
`;

Expand Down Expand Up @@ -226,54 +186,6 @@ exports[`full integration test synth synth generates JSON 1`] = `
},
"provider": "aws"
}
},
"aws_wafv2_web_acl": {
"wafv2": {
"//": {
"metadata": {
"path": "hello-terra/wafv2",
"uniqueId": "wafv2"
}
},
"default_action": {
"allow": {}
},
"name": "managed-rule-example",
"rule": [
{
"name": "managed-rule-example",
"override_action": {
"count": {}
},
"priority": 1,
"statement": {
"managed_rule_group_statement": {
"excluded_rule": [
{
"name": "SizeRestrictions_QUERYSTRING"
},
{
"name": "SQLInjection_QUERYSTRING"
}
],
"name": "managed-rule-example",
"vendor_name": "AWS"
}
},
"visibility_config": {
"cloudwatch_metrics_enabled": true,
"metric_name": "managed-rule-example",
"sampled_requests_enabled": true
}
}
],
"scope": "REGIONAL",
"visibility_config": {
"cloudwatch_metrics_enabled": true,
"metric_name": "managed-rule-example",
"sampled_requests_enabled": true
}
}
}
},
"terraform": {
Expand Down
40 changes: 0 additions & 40 deletions test/typescript/synth-app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "cdktf";
import { provider, snsTopic } from "./.gen/providers/aws";
import { Instance } from "./.gen/providers/aws/instance";
import { Wafv2WebAcl } from "./.gen/providers/aws/wafv2-web-acl";

export class HelloTerra extends TerraformStack {
constructor(scope: Construct, id: string) {
Expand Down Expand Up @@ -85,45 +84,6 @@ export class HelloTerra extends TerraformStack {
},
},
});

new Wafv2WebAcl(this, "wafv2", {
defaultAction: {
allow: {},
},
name: "managed-rule-example",
scope: "REGIONAL",
visibilityConfig: {
cloudwatchMetricsEnabled: true,
metricName: "managed-rule-example",
sampledRequestsEnabled: true,
},
rule: [
{
name: "managed-rule-example",
priority: 1,
overrideAction: {
count: {},
},
visibilityConfig: {
cloudwatchMetricsEnabled: true,
metricName: "managed-rule-example",
sampledRequestsEnabled: true,
},
statement: {
managedRuleGroupStatement: {
name: "managed-rule-example",
vendorName: "AWS",
excludedRule: [
{
name: "SizeRestrictions_QUERYSTRING",
},
{ name: "SQLInjection_QUERYSTRING" },
],
},
},
},
],
});
}
}

Expand Down
Loading