Add aws_default_security_group

main
William Beuil 2021-04-26 17:24:57 +02:00
parent 4aa06223da
commit ef935fb77f
No known key found for this signature in database
GPG Key ID: BED2072C5C2BF537
7 changed files with 59841 additions and 10466 deletions

View File

@ -15,5 +15,42 @@
"VpcId": "vpc-618f6e09",
"Timeouts": null,
"CtyVal": {}
},
{
"Id": "sg-9e0204ff",
"Type": "aws_default_security_group",
"Attrs": {
"arn": "arn:aws:ec2:eu-west-3:047081014315:security-group/sg-9e0204ff",
"description": "default VPC security group",
"egress": [
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 0,
"protocol": "-1",
"self": false,
"to_port": 0
}
],
"id": "sg-9e0204ff",
"ingress": [
{
"description": "",
"from_port": 0,
"protocol": "-1",
"self": true,
"to_port": 0
}
],
"name": "default",
"owner_id": "047081014315",
"revoke_rules_on_delete": false,
"tags": {
"Name": "DEFAULT"
},
"vpc_id": "vpc-618f6e09"
}
}
]

View File

@ -0,0 +1,39 @@
provider "aws" {
region = "us-east-1"
}
terraform {
required_providers {
aws = "3.19.0"
}
}
resource "aws_default_security_group" "default" {
tags = {
Name = "Default Security Group"
}
}
resource "aws_security_group" "foo" {
name = "foo"
ingress {
description = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
description = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "Foo Security Group"
}
}

View File

@ -5,6 +5,58 @@
"lineage": "8e8cf992-f0f7-d359-da78-320927a8879c",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "aws_default_security_group",
"name": "test-default-sg",
"provider": "provider.aws",
"instances": [
{
"schema_version": 1,
"attributes": {
"arn": "arn:aws:ec2:eu-west-3:047081014315:security-group/sg-9e0204ff",
"description": "default VPC security group",
"egress": [
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 0,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "-1",
"security_groups": [],
"self": false,
"to_port": 0
}
],
"id": "sg-9e0204ff",
"ingress": [
{
"cidr_blocks": [],
"description": "",
"from_port": 0,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "-1",
"security_groups": [],
"self": true,
"to_port": 0
}
],
"name": "default",
"owner_id": "047081014315",
"revoke_rules_on_delete": false,
"tags": {
"Name": "DEFAULT"
},
"vpc_id": "vpc-618f6e09"
},
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="
}
]
},
{
"mode": "managed",
"type": "aws_security_group",

View File

@ -1,7 +1,10 @@
// GENERATED, DO NOT EDIT THIS FILE
package aws
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const AwsDefaultSecurityGroupResourceType = "aws_default_security_group"
@ -50,3 +53,11 @@ func (r *AwsDefaultSecurityGroup) TerraformType() string {
func (r *AwsDefaultSecurityGroup) CtyValue() *cty.Value {
return r.CtyVal
}
func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(val *resource.Attributes) {
val.SafeDelete([]string{"revoke_rules_on_delete"})
val.SafeDelete([]string{"ingress"})
val.SafeDelete([]string{"egress"})
})
}

View File

@ -7,4 +7,5 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
initAwsCloudfrontDistributionMetaData(resourceSchemaRepository)
initAwsDbInstanceMetaData(resourceSchemaRepository)
initAwsDbSubnetGroupMetaData(resourceSchemaRepository)
initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository)
}

View File

@ -24,6 +24,7 @@ var refactoredResources = []string{
"aws_db_instance",
"aws_db_subnet_group",
"aws_default_route_table",
"aws_default_security_group",
}
func IsRefactoredResource(typ string) bool {