Skip to content

Commit

Permalink
datasource aws update
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Feb 10, 2025
1 parent 1b5536b commit 1a0cb7b
Show file tree
Hide file tree
Showing 16 changed files with 2,916 additions and 2,877 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,20 @@ func main() {
return err
}
if Difference.Under != nil {

fmt.Println("The following are under-permissive: ")

for _, v := range Difference.Under {
fmt.Println(v)
}

return errors.New("under-permissive")
}

if Difference.Over != nil {

fmt.Println("The following are over-permissive: ")

for _, v := range Difference.Over {
fmt.Println(v)
}
Expand Down
2 changes: 2 additions & 0 deletions src/aws_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ var tFLookupDataAWS = map[string]interface{}{
"aws_route53_records": dataAwsRoute53Records,
"aws_cloudwatch_event_buses": dataAwsCloudwatchEventBuses,
"aws_ecs_clusters": dataAwsEcsClusters,
"aws_vpc_ipam": dataAwsVpcIpam,
"aws_vpc_ipams": dataAwsVpcIpam,
}

// GetAWSDataPermissions gets permissions required for datasource's.
Expand Down
2 changes: 1 addition & 1 deletion src/azure_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func AZUREPolicy(permissions []string, policyName string) (string, error) {
}

if policyName == "" {
policyName = DefaultPolicyName
policyName = defaultPolicyName
}

theDetails := azurePolicyDetails{policyName, test}
Expand Down
2 changes: 1 addition & 1 deletion src/coverage/aws.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# todo aws

Resource percentage coverage 93.16
Datasource percentage coverage 100.00
Datasource percentage coverage 99.65

./resource.ps1 aws_cognito_managed_user_pool_client
./resource.ps1 aws_ebs_fast_snapshot_restore
Expand Down
4 changes: 3 additions & 1 deletion src/coverage/azure.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# todo azure

Resource percentage coverage 4.58
Resource percentage coverage 4.57
Datasource percentage coverage 35.57

./resource.ps1 azurerm_aadb2c_directory
Expand Down Expand Up @@ -177,6 +177,7 @@ Datasource percentage coverage 35.57
./resource.ps1 azurerm_chaos_studio_target
./resource.ps1 azurerm_cognitive_account_customer_managed_key
./resource.ps1 azurerm_cognitive_account_rai_blocklist
./resource.ps1 azurerm_cognitive_account_rai_policy
./resource.ps1 azurerm_cognitive_deployment
./resource.ps1 azurerm_communication_service
./resource.ps1 azurerm_communication_service_email_domain_association
Expand Down Expand Up @@ -586,6 +587,7 @@ Datasource percentage coverage 35.57
./resource.ps1 azurerm_mssql_job_agent
./resource.ps1 azurerm_mssql_job_credential
./resource.ps1 azurerm_mssql_job_schedule
./resource.ps1 azurerm_mssql_job_target_group
./resource.ps1 azurerm_mssql_managed_database
./resource.ps1 azurerm_mssql_managed_instance
./resource.ps1 azurerm_mssql_managed_instance_active_directory_administrator
Expand Down
11 changes: 9 additions & 2 deletions src/coverage/google.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# todo google

Resource percentage coverage 18.41
Datasource percentage coverage 72.11
Resource percentage coverage 18.34
Datasource percentage coverage 71.47

./resource.ps1 google_access_context_manager_access_level_condition
./resource.ps1 google_access_context_manager_service_perimeter_dry_run_egress_policy
Expand Down Expand Up @@ -58,6 +58,9 @@ Datasource percentage coverage 72.11
./resource.ps1 google_beyondcorp_app_connector
./resource.ps1 google_beyondcorp_app_gateway
./resource.ps1 google_beyondcorp_security_gateway
./resource.ps1 google_beyondcorp_security_gateway_iam_binding
./resource.ps1 google_beyondcorp_security_gateway_iam_member
./resource.ps1 google_beyondcorp_security_gateway_iam_policy
./resource.ps1 google_biglake_catalog
./resource.ps1 google_biglake_database
./resource.ps1 google_biglake_table
Expand Down Expand Up @@ -136,6 +139,7 @@ Datasource percentage coverage 72.11
./resource.ps1 google_cloudfunctions2_function_iam_policy
./resource.ps1 google_cloudfunctions_function_iam_binding
./resource.ps1 google_cloudiot_registry
./resource.ps1 google_colab_notebook_execution
./resource.ps1 google_colab_runtime
./resource.ps1 google_colab_runtime_template
./resource.ps1 google_colab_runtime_template_iam_binding
Expand Down Expand Up @@ -873,6 +877,7 @@ Datasource percentage coverage 72.11
./resource.ps1 google_backup_dr_backup_plan_association -type data
./resource.ps1 google_backup_dr_backup_vault -type data
./resource.ps1 google_backup_dr_data_source -type data
./resource.ps1 google_beyondcorp_security_gateway_iam_policy -type data
./resource.ps1 google_bigquery_tables -type data
./resource.ps1 google_certificate_manager_certificates -type data
./resource.ps1 google_cloud_identity_group_transitive_memberships -type data
Expand Down Expand Up @@ -925,8 +930,10 @@ Datasource percentage coverage 72.11
./resource.ps1 google_organizations -type data
./resource.ps1 google_parameter_manager_parameter -type data
./resource.ps1 google_parameter_manager_parameter_version -type data
./resource.ps1 google_parameter_manager_parameter_version_render -type data
./resource.ps1 google_parameter_manager_parameters -type data
./resource.ps1 google_parameter_manager_regional_parameter -type data
./resource.ps1 google_parameter_manager_regional_parameter_version -type data
./resource.ps1 google_parameter_manager_regional_parameters -type data
./resource.ps1 google_privateca_ca_pool_iam_policy -type data
./resource.ps1 google_privateca_certificate_authority -type data
Expand Down
32 changes: 31 additions & 1 deletion src/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ func TestAssertionFailedError(t *testing.T) {
}

func TestInvalidJSONError(t *testing.T) {
t.Parallel()
t.Run("implements error interface", func(t *testing.T) {
t.Parallel()

Expand All @@ -475,6 +476,8 @@ func TestInvalidJSONError(t *testing.T) {
}

func TestUnmarshallJSONError(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
err error
Expand Down Expand Up @@ -504,6 +507,7 @@ func TestUnmarshallJSONError(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

err := &unmarshallJSONError{
err: tc.err,
resource: tc.resource,
Expand All @@ -526,6 +530,8 @@ func TestAttributesFieldMissingError(t *testing.T) {
}

func TestAssertionError(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
message string
Expand All @@ -545,7 +551,10 @@ func TestAssertionError(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

err := &assertionError{message: tc.message}

if got := err.Error(); got != tc.want {
t.Errorf("assertionError.Error() = %v, want %v", got, tc.want)
}
Expand All @@ -554,6 +563,8 @@ func TestAssertionError(t *testing.T) {
}

func TestTemplateParseError(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
err error
Expand All @@ -573,7 +584,10 @@ func TestTemplateParseError(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

err := &templateParseError{err: tc.err}

if got := err.Error(); got != tc.want {
t.Errorf("templateParseError.Error() = %v, want %v", got, tc.want)
}
Expand All @@ -582,6 +596,8 @@ func TestTemplateParseError(t *testing.T) {
}

func TestTemplateExecuteError(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
err error
Expand All @@ -601,7 +617,10 @@ func TestTemplateExecuteError(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

err := &templateExecuteError{err: tc.err}

if got := err.Error(); got != tc.want {
t.Errorf("templateExecuteError.Error() = %v, want %v", got, tc.want)
}
Expand All @@ -610,6 +629,8 @@ func TestTemplateExecuteError(t *testing.T) {
}

func TestMarshallAWSPolicyError(t *testing.T) {
t.Parallel()

tests := []struct {
name string
err error
Expand All @@ -634,7 +655,10 @@ func TestMarshallAWSPolicyError(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

err := &marshallAWSPolicyError{err: tt.err}

if got := err.Error(); got != tt.expected {
t.Errorf("marshallAWSPolicyError.Error() = %v, want %v", got, tt.expected)
}
Expand All @@ -644,6 +668,8 @@ func TestMarshallAWSPolicyError(t *testing.T) {

func TestDirectoryErrors(t *testing.T) {
t.Run("empty directory error", func(t *testing.T) {
t.Parallel()

err := &emptyDirectoryError{}
expected := "directory value cannot be an empty string"

Expand Down Expand Up @@ -674,7 +700,9 @@ func TestARNErrors(t *testing.T) {

t.Run("invalid ARN error", func(t *testing.T) {
t.Parallel()

err := &invalidARNError{arn: "invalid:arn"}

expected := "invalid ARN: invalid:arn"

if err.Error() != expected {
Expand All @@ -684,10 +712,12 @@ func TestARNErrors(t *testing.T) {
}

func TestAWSErrors(t *testing.T) {

t.Parallel()
t.Run("AWS config error", func(t *testing.T) {
t.Parallel()

err := &awsConfigError{err: &emptyNameError{}}

expected := "failed to load AWS config: Name cannot be empty"

if err.Error() != expected {
Expand Down
3 changes: 3 additions & 0 deletions src/files_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,3 +1551,6 @@ var dataAwsCloudwatchEventBuses []byte

//go:embed mapping/aws/data/ecs/aws_ecs_clusters.json
var dataAwsEcsClusters []byte

//go:embed mapping/aws/data/ec2/aws_vpc_ipam.json
var dataAwsVpcIpam []byte
12 changes: 6 additions & 6 deletions src/gcp_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
)

const (
DefaultPolicyName = "terraform_pike"
DefaultProject = "pike"
DefaultRoleID = "terraform_pike"
defaultPolicyName = "terraform_pike"
defaultProject = "pike"
defaultRoleID = "terraform_pike"
)

//go:embed terraform.gcppolicy.template
Expand All @@ -32,11 +32,11 @@ func GCPPolicy(permissions []string) (string, error) {
Permissions string // Comma-separated list of permissions
}

PolicyName := DefaultPolicyName
PolicyName := defaultPolicyName
theDetails := gCPPolicyDetails{
Name: PolicyName,
Project: DefaultProject,
RoleID: DefaultRoleID,
Project: defaultProject,
RoleID: defaultRoleID,
Permissions: test,
}

Expand Down
13 changes: 13 additions & 0 deletions src/mapping/aws/data/ec2/aws_vpc_ipam.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"ec2:DescribeIpams"
]
}
]
Loading

0 comments on commit 1a0cb7b

Please sign in to comment.