Ignore unsupported resource from IaC
parent
c35389431f
commit
646c6a392c
|
@ -70,6 +70,15 @@ func (r *TerraformStateReader) retrieve() (map[string][]cty.Value, error) {
|
|||
for _, stateRes := range module.Resources {
|
||||
resName := stateRes.Addr.Resource.Name
|
||||
resType := stateRes.Addr.Resource.Type
|
||||
|
||||
if !resource.IsResourceTypeSupported(resType) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"name": resName,
|
||||
"type": resType,
|
||||
}).Debug("Ignored unsupported resource from state")
|
||||
continue
|
||||
}
|
||||
|
||||
if stateRes.Addr.Resource.Mode != addrs.ManagedResourceMode {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"mode": stateRes.Addr.Resource.Mode,
|
||||
|
@ -160,9 +169,6 @@ func (r *TerraformStateReader) decode(values map[string][]cty.Value) ([]resource
|
|||
results := make([]resource.Resource, 0)
|
||||
|
||||
for ty, val := range values {
|
||||
if !resource.IsResourceTypeSupported(ty) {
|
||||
continue
|
||||
}
|
||||
decodedResources, err := r.deserializer.Deserialize(ty, val)
|
||||
if err != nil {
|
||||
logrus.WithField("ty", ty).Warnf("Could not read from state: %+v", err)
|
||||
|
|
|
@ -61,6 +61,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
|
|||
{name: "Lambda function", dirName: "lambda_function", wantErr: false},
|
||||
{name: "unsupported attribute", dirName: "unsupported_attribute", wantErr: false},
|
||||
{name: "Unsupported provider", dirName: "unsupported_provider", wantErr: false},
|
||||
{name: "Unsupported resource", dirName: "unsupported_resource", wantErr: false},
|
||||
{name: "EC2 instance", dirName: "ec2_instance", wantErr: false},
|
||||
{name: "EC2 key pair", dirName: "ec2_key_pair", wantErr: false},
|
||||
{name: "EC2 ami", dirName: "ec2_ami", wantErr: false},
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.15.5",
|
||||
"serial": 52,
|
||||
"lineage": "06b3de6d-5de6-0777-b4db-f1b145a44635",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_codedeploy_app",
|
||||
"name": "example",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"application_id": "94e6e3fd-5743-4818-bf3d-2d31f139d859",
|
||||
"arn": "arn:aws:codedeploy:eu-west-3:929327065333:application:example",
|
||||
"compute_platform": "ECS",
|
||||
"github_account_name": "",
|
||||
"id": "94e6e3fd-5743-4818-bf3d-2d31f139d859:example",
|
||||
"linked_to_github": false,
|
||||
"name": "example",
|
||||
"tags": null,
|
||||
"tags_all": {}
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue