-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AwsEksAudit): Add support for AwsEksAudit apiv2 cloud account in…
…tegration (#292) * feat(AwsEksAudit): Add support for AwsEksAudit apiv2 cloud account integration Signed-off-by: Ross <[email protected]>
- Loading branch information
Showing
51 changed files
with
635 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.16.0 | ||
1.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
examples/resource_lacework_integration_aws_eks_audit_log/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
terraform { | ||
required_providers { | ||
lacework = { | ||
source = "lacework/lacework" | ||
} | ||
} | ||
} | ||
|
||
variable "name" { | ||
type = string | ||
default = "AWS EKS audit log integration example" | ||
} | ||
|
||
variable "sns_arn" { | ||
type = string | ||
default = "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks" | ||
} | ||
|
||
variable "external_id" { | ||
type = string | ||
default = "12345" | ||
} | ||
|
||
variable "role_arn" { | ||
type = string | ||
default = "arn:aws:iam::249446771485:role/lacework-iam-example-role" | ||
} | ||
|
||
resource "lacework_integration_aws_eks_audit_log" "example" { | ||
name = var.name | ||
sns_arn = var.sns_arn | ||
credentials { | ||
role_arn = var.role_arn | ||
external_id = var.external_id | ||
} | ||
retries = 10 | ||
} | ||
|
||
output "name" { | ||
value = lacework_integration_aws_eks_audit_log.example.name | ||
} | ||
|
||
output "sns_arn" { | ||
value = lacework_integration_aws_eks_audit_log.example.sns_arn | ||
} | ||
|
||
output "role_arn" { | ||
value = lacework_integration_aws_eks_audit_log.example.credentials[0].role_arn | ||
} | ||
|
||
output "external_id" { | ||
value = lacework_integration_aws_eks_audit_log.example.credentials[0].external_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
integration/resource_lacework_integration_aws_eks_audit_log_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestIntegrationAwsEksAuditLog applies integration terraform: | ||
// => '../examples/resource_lacework_integration_aws_eks_audit_log' | ||
// | ||
// It uses the go-sdk to verify the created integration, | ||
// applies an update with new integration name and destroys it | ||
func TestIntegrationAwsEksAuditLog(t *testing.T) { | ||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../examples/resource_lacework_integration_aws_eks_audit_log", | ||
Vars: map[string]interface{}{ | ||
"role_arn": "arn:aws:iam::249446771485:role/lacework-iam-example-role", | ||
"external_id": "12345", | ||
"sns_arn": "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", | ||
}, | ||
}) | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// Create new AwsEksAudit Integration | ||
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions) | ||
createData := GetCloudAccountEksAuditLogData(create) | ||
actualRoleArn := terraform.Output(t, terraformOptions, "role_arn") | ||
actualExternalId := terraform.Output(t, terraformOptions, "external_id") | ||
actualSnsArn := terraform.Output(t, terraformOptions, "sns_arn") | ||
assert.Equal( | ||
t, | ||
"AWS EKS audit log integration example", | ||
GetCloudAccountIntegrationName(create), | ||
) | ||
assert.Equal(t, "arn:aws:iam::249446771485:role/lacework-iam-example-role", createData.Credentials.RoleArn) | ||
assert.Equal(t, "12345", createData.Credentials.ExternalID) | ||
assert.Equal(t, "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", createData.SnsArn) | ||
assert.Equal(t, "arn:aws:iam::249446771485:role/lacework-iam-example-role", actualRoleArn) | ||
assert.Equal(t, "12345", actualExternalId) | ||
assert.Equal(t, "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", actualSnsArn) | ||
|
||
// Update AwsEksAudit Integration | ||
terraformOptions.Vars = map[string]interface{}{ | ||
"name": "AwsEksAudit log integration updated", | ||
"role_arn": "arn:aws:iam::249446771485:role/lacework-iam-example-role", | ||
"external_id": "12345", | ||
"sns_arn": "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", | ||
} | ||
|
||
update := terraform.ApplyAndIdempotent(t, terraformOptions) | ||
updateData := GetCloudAccountEksAuditLogData(update) | ||
actualRoleArn = terraform.Output(t, terraformOptions, "role_arn") | ||
actualExternalId = terraform.Output(t, terraformOptions, "external_id") | ||
actualSnsArn = terraform.Output(t, terraformOptions, "sns_arn") | ||
assert.Equal( | ||
t, | ||
"AwsEksAudit log integration updated", | ||
GetCloudAccountIntegrationName(update), | ||
) | ||
assert.Equal(t, "arn:aws:iam::249446771485:role/lacework-iam-example-role", updateData.Credentials.RoleArn) | ||
assert.Equal(t, "12345", updateData.Credentials.ExternalID) | ||
assert.Equal(t, "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", updateData.SnsArn) | ||
assert.Equal(t, "arn:aws:iam::249446771485:role/lacework-iam-example-role", actualRoleArn) | ||
assert.Equal(t, "12345", actualExternalId) | ||
assert.Equal(t, "arn:aws:sns:us-west-2:123456789123:foo-lacework-eks", actualSnsArn) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.