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

Ignore arn attribute for some AWS resources #1578

Merged
merged 2 commits into from
Aug 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"Type": "aws_instance",
"Attrs": {
"ami": "ami-0697b068b80d79421",
"arn": "arn:aws:ec2:eu-west-3:047081014315:instance/i-0d3650a23f4e45dc0",
"associate_public_ip_address": true,
"availability_zone": "eu-west-3b",
"cpu_core_count": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Id": "igw-0184eb41aadc62d1c",
"Type": "aws_internet_gateway",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:047081014315:internet-gateway/igw-0184eb41aadc62d1c",
"id": "igw-0184eb41aadc62d1c",
"owner_id": "047081014315",
"tags": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Id": "lt-0ed993d09ce6afc67",
"Type": "aws_launch_template",
"Attrs": {
"arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-0ed993d09ce6afc67",
"block_device_mappings": [
{
"device_name": "/dev/sda1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"Id": "igw-00e1a78d127606c92",
"Type": "aws_internet_gateway",
"Attrs": {
"arn": "arn:aws:ec2:us-east-1:533948124879:internet-gateway/igw-00e1a78d127606c92",
"id": "igw-00e1a78d127606c92",
"owner_id": "533948124879",
"vpc_id": "vpc-069eb1208f4f62f3c"
Expand Down
1 change: 0 additions & 1 deletion pkg/iac/terraform/state/test/aws_vpc/results.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"Id": "vpc-0a5666c0cfc366714",
"Type": "aws_vpc",
"Attrs": {
"arn": "arn:aws:ec2:us-east-1:929327065333:vpc/vpc-0a5666c0cfc366714",
"assign_generated_ipv6_cidr_block": false,
"cidr_block": "10.0.0.0/16",
"default_network_acl_id": "acl-081a06acb9d092caf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"Type": "aws_instance",
"Attrs": {
"ami": "ami-0f8e5edde3a79f541",
"arn": "arn:aws:ec2:eu-west-3:929327065333:instance/i-002c7d44410fee60e",
"associate_public_ip_address": true,
"availability_zone": "eu-west-3a",
"cpu_core_count": 1,
Expand Down
1 change: 1 addition & 0 deletions pkg/resource/aws/aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func initAwsInstanceMetaData(resourceSchemaRepository dctlresource.SchemaReposit
resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) {
val := res.Attrs
val.SafeDelete([]string{"timeouts"})
val.SafeDelete([]string{"arn"})

if v, _ := version.NewVersion("3.38.0"); res.Schema().ProviderVersion.LessThan(v) {
val.SafeDelete([]string{"instance_initiated_shutdown_behavior"})
Expand Down
3 changes: 3 additions & 0 deletions pkg/resource/aws/aws_internet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ import (
const AwsInternetGatewayResourceType = "aws_internet_gateway"

func initAwsInternetGatewayMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsInternetGatewayResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"arn"})
})
resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode)
}
3 changes: 3 additions & 0 deletions pkg/resource/aws/aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ import (
const AwsLaunchTemplateResourceType = "aws_launch_template"

func initAwsLaunchTemplateMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsLaunchTemplateResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"arn"})
})
resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode)
}
3 changes: 3 additions & 0 deletions pkg/resource/aws/aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ import (
const AwsVpcResourceType = "aws_vpc"

func initAwsVpcMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsVpcResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"arn"})
})
resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode)
}
1 change: 0 additions & 1 deletion pkg/test/aws/3.19.0/aws_internet_gateway/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Id": "igw-0184eb41aadc62d1c",
"Type": "aws_internet_gateway",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:047081014315:internet-gateway/igw-0184eb41aadc62d1c",
"id": "igw-0184eb41aadc62d1c",
"owner_id": "047081014315",
"tags": {
Expand Down
2 changes: 0 additions & 2 deletions pkg/test/aws/3.19.0/aws_launch_template/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Id": "lt-00b2d18c6cee7fe23",
"Type": "aws_launch_template",
"Attrs": {
"arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-00b2d18c6cee7fe23",
"default_version": 1,
"description": "",
"disable_api_termination": false,
Expand All @@ -24,7 +23,6 @@
"Id": "lt-0ed993d09ce6afc67",
"Type": "aws_launch_template",
"Attrs": {
"arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-0ed993d09ce6afc67",
"block_device_mappings": [
{
"device_name": "/dev/sda1",
Expand Down
3 changes: 0 additions & 3 deletions pkg/test/aws/3.19.0/aws_vpc/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Id": "vpc-02c50896b59598761",
"Type": "aws_vpc",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-02c50896b59598761",
"assign_generated_ipv6_cidr_block": false,
"cidr_block": "10.0.0.0/16",
"default_network_acl_id": "acl-0acd66b145f6f2102",
Expand All @@ -24,7 +23,6 @@
"Id": "vpc-0768e1fd0029e3fc3",
"Type": "aws_vpc",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-0768e1fd0029e3fc3",
"assign_generated_ipv6_cidr_block": false,
"cidr_block": "10.1.0.0/16",
"default_network_acl_id": "acl-0d17964d633baf4b3",
Expand All @@ -45,7 +43,6 @@
"Id": "vpc-020b072316a95b97f",
"Type": "aws_vpc",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-020b072316a95b97f",
"assign_generated_ipv6_cidr_block": false,
"cidr_block": "10.2.0.0/16",
"default_network_acl_id": "acl-0ff5d175a1aa8f51a",
Expand Down