Merge branch 'main' into test/cacheEC2repo

main
Raphaël 2021-06-04 15:30:06 +02:00 committed by GitHub
commit 8d84f4ec52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 0 deletions

View File

@ -158,6 +158,9 @@ func (r *TerraformStateReader) decode(values map[string][]cty.Value) ([]resource
results := make([]resource.Resource, 0) results := make([]resource.Resource, 0)
for ty, val := range values { for ty, val := range values {
if !resource.IsResourceTypeSupported(ty) {
continue
}
decodedResources, err := r.deserializer.Deserialize(ty, val) decodedResources, err := r.deserializer.Deserialize(ty, val)
if err != nil { if err != nil {
logrus.WithField("ty", ty).Warnf("Could not read from state: %+v", err) logrus.WithField("ty", ty).Warnf("Could not read from state: %+v", err)

View File

@ -2,6 +2,72 @@ package resource
type ResourceType string type ResourceType string
var supportedTypes = map[string]struct{}{
"aws_ami": {},
"aws_cloudfront_distribution": {},
"aws_db_instance": {},
"aws_db_subnet_group": {},
"aws_default_route_table": {},
"aws_default_security_group": {},
"aws_default_subnet": {},
"aws_default_vpc": {},
"aws_dynamodb_table": {},
"aws_ebs_snapshot": {},
"aws_ebs_volume": {},
"aws_ecr_repository": {},
"aws_eip": {},
"aws_eip_association": {},
"aws_iam_access_key": {},
"aws_iam_policy": {},
"aws_iam_policy_attachment": {},
"aws_iam_role": {},
"aws_iam_role_policy": {},
"aws_iam_role_policy_attachment": {},
"aws_iam_user": {},
"aws_iam_user_policy": {},
"aws_iam_user_policy_attachment": {},
"aws_instance": {},
"aws_internet_gateway": {},
"aws_key_pair": {},
"aws_kms_alias": {},
"aws_kms_key": {},
"aws_lambda_event_source_mapping": {},
"aws_lambda_function": {},
"aws_nat_gateway": {},
"aws_route": {},
"aws_route53_health_check": {},
"aws_route53_record": {},
"aws_route53_zone": {},
"aws_route_table": {},
"aws_route_table_association": {},
"aws_s3_bucket": {},
"aws_s3_bucket_analytics_configuration": {},
"aws_s3_bucket_inventory": {},
"aws_s3_bucket_metric": {},
"aws_s3_bucket_notification": {},
"aws_s3_bucket_policy": {},
"aws_security_group": {},
"aws_security_group_rule": {},
"aws_sns_topic": {},
"aws_sns_topic_policy": {},
"aws_sns_topic_subscription": {},
"aws_sqs_queue": {},
"aws_sqs_queue_policy": {},
"aws_subnet": {},
"aws_vpc": {},
"github_branch_protection": {},
"github_membership": {},
"github_repository": {},
"github_team": {},
"github_team_membership": {},
}
func IsResourceTypeSupported(ty string) bool {
_, exist := supportedTypes[ty]
return exist
}
func (ty ResourceType) String() string { func (ty ResourceType) String() string {
return string(ty) return string(ty)
} }