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

AL-3019 - Add support to licensed image #234

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions dome9/common/testing/variable/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ const (
MaxConcurrentScansPerRegionUpdate = "8"
InAccountScannerVPC = "ManagedByAWP"
InAccountScannerVPCUpdate = "ManagedByCustomer"
ScanAWSLicensedImages = "false"
ScanAWSLicensedImagesUpdate = "true"
CustomTags = `{
tag1 = "value1"
tag2 = "value2"
Expand Down
5 changes: 5 additions & 0 deletions dome9/data_source_dome9_awp_aws_onboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func dataSourceAwpAwsOnboarding() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"scan_aws_licensed_images": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"custom_tags": {
Type: schema.TypeMap,
Computed: true,
Expand Down
1 change: 1 addition & 0 deletions dome9/data_source_dome9_awp_aws_onboarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestAccDataSourceAwpAwsOnboardingBasic(t *testing.T) {
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_account_settings.0.scan_machine_interval_in_hours", awpAwsOnboardingResourceTypeAndName, "agentless_account_settings.0.scan_machine_interval_in_hours"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_account_settings.0.max_concurrent_scans_per_region", awpAwsOnboardingResourceTypeAndName, "agentless_account_settings.0.max_concurrent_scans_per_region"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_account_settings.0.in_account_scanner_vpc", awpAwsOnboardingResourceTypeAndName, "agentless_account_settings.0.in_account_scanner_vpc"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_account_settings.0.scan_aws_licensed_images", awpAwsOnboardingResourceTypeAndName, "agentless_account_settings.0.scan_aws_licensed_images"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_account_settings.0.custom_tags.%", awpAwsOnboardingResourceTypeAndName, "agentless_account_settings.0.custom_tags.%"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "missing_awp_private_network_regions", awpAwsOnboardingResourceTypeAndName, "missing_awp_private_network_regions"),
resource.TestCheckResourceAttrPair(awpAwsOnboardingDataSourceTypeAndName, "agentless_protection_enabled", awpAwsOnboardingResourceTypeAndName, "agentless_protection_enabled"),
Expand Down
11 changes: 11 additions & 0 deletions dome9/resource_dome9_awp_aws_onboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func resourceAwpAwsOnboarding() *schema.Resource {
Optional: true,
Default: "ManagedByAWP",
},
"scan_aws_licensed_images": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"custom_tags": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -276,6 +281,7 @@ func expandAgentlessAccountSettings(d *schema.ResourceData) (*awp_onboarding.Age
ScanMachineIntervalInHours: scanMachineIntervalInHours,
InAccountScannerVPC: providerconst.DefaultInAccountScannerVPCMode,
MaxConcurrenceScansPerRegion: providerconst.DefaultMaxConcurrentScansPerRegion,
ScanAWSLicensedImages: false,
}

// Check if the key exists and is not nil
Expand Down Expand Up @@ -311,6 +317,10 @@ func expandAgentlessAccountSettings(d *schema.ResourceData) (*awp_onboarding.Age
agentlessAccountSettings.InAccountScannerVPC = inAccountScannerVPC
}

if ScanAWSLicensedImages, ok := agentlessAccountSettingsMap["scan_aws_licensed_images"].(bool); ok {
agentlessAccountSettings.ScanAWSLicensedImages = ScanAWSLicensedImages
}

if customTagsInterface, ok := agentlessAccountSettingsMap["custom_tags"].(map[string]interface{}); ok {
customTags := make(map[string]string)
for k, v := range customTagsInterface {
Expand Down Expand Up @@ -344,6 +354,7 @@ func flattenAgentlessAccountSettings(settings *awp_onboarding.AgentlessAccountSe
"scan_machine_interval_in_hours": settings.ScanMachineIntervalInHours,
"max_concurrent_scans_per_region": settings.MaxConcurrenceScansPerRegion,
"in_account_scanner_vpc": settings.InAccountScannerVPC,
"scan_aws_licensed_images": settings.ScanAWSLicensedImages,
"custom_tags": settings.CustomTags,
}
return []interface{}{m}
Expand Down
4 changes: 4 additions & 0 deletions dome9/resource_dome9_awp_aws_onboarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestAccResourceAWPAWSOnboardingBasic(t *testing.T) {
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.scan_machine_interval_in_hours", variable.ScanMachineIntervalInHours),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.max_concurrent_scans_per_region", variable.MaxConcurrentScansPerRegion),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.in_account_scanner_vpc", variable.InAccountScannerVPC),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.scan_aws_licensed_images", variable.ScanAWSLicensedImages),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.custom_tags.%", "2"),
resource.TestCheckResourceAttrSet(resourceTypeAndName, "id"),
resource.TestCheckResourceAttr(resourceTypeAndName, "cloud_provider", "aws"),
Expand All @@ -74,6 +75,7 @@ func TestAccResourceAWPAWSOnboardingBasic(t *testing.T) {
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.scan_machine_interval_in_hours", variable.ScanMachineIntervalInHoursUpdate),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.max_concurrent_scans_per_region", variable.MaxConcurrentScansPerRegionUpdate),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.in_account_scanner_vpc", variable.InAccountScannerVPCUpdate),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.scan_aws_licensed_images", variable.ScanAWSLicensedImagesUpdate),
resource.TestCheckResourceAttr(resourceTypeAndName, "agentless_account_settings.0.custom_tags.%", "3"),
resource.TestCheckResourceAttrSet(resourceTypeAndName, "id"),
resource.TestCheckResourceAttr(resourceTypeAndName, "cloud_provider", "aws"),
Expand Down Expand Up @@ -159,6 +161,7 @@ resource "%s" "%s" {
scan_machine_interval_in_hours = "%s"
max_concurrent_scans_per_region = "%s"
in_account_scanner_vpc = "%s"
scan_aws_licensed_images = "%s"
custom_tags = %s
}
awp_version = "%s"
Expand All @@ -174,6 +177,7 @@ resource "%s" "%s" {
IfThenElse(updateAction, variable.ScanMachineIntervalInHoursUpdate, variable.ScanMachineIntervalInHours),
IfThenElse(updateAction, variable.MaxConcurrentScansPerRegionUpdate, variable.MaxConcurrentScansPerRegion),
IfThenElse(updateAction, variable.InAccountScannerVPCUpdate, variable.InAccountScannerVPC),
IfThenElse(updateAction, variable.ScanAWSLicensedImagesUpdate, variable.ScanAWSLicensedImages),
IfThenElse(updateAction, variable.CustomTagsUpdate, variable.CustomTags),
"10",
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading