Skip to content

Commit

Permalink
resource group
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Dec 18, 2022
1 parent ca9a514 commit dccaebe
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ func GetAWSResourcePermissions(result ResourceV2) ([]string, error) {
"aws_xray_group": awsXrayGroup,
"aws_xray_sampling_rule": awsXraySamplingRule,
"aws_kms_grant": awsKmsGrant,
"aws_applicationinsights_application": awsApplicationinsightsApplication,
"aws_resourcegroups_group": awsResourcegroupsGroup,
}

var Permissions []string
Expand Down
6 changes: 6 additions & 0 deletions src/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,3 +993,9 @@ var awsXraySamplingRule []byte

//go:embed mapping/aws/resource/kms/aws_kms_grant.json
var awsKmsGrant []byte

//go:embed mapping/aws/resource/applicationinsights/aws_applicationinsights_application.json
var awsApplicationinsightsApplication []byte

//go:embed mapping/aws/resource/resource-groups/aws_resourcegroups_group.json
var awsResourcegroupsGroup []byte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"apply": [
"applicationinsights:CreateApplication",
"iam:CreateServiceLinkedRole",
"logs:DescribeLogGroups",
"applicationinsights:DescribeApplication",
"applicationinsights:ListTagsForResource",
"applicationinsights:DeleteApplication"
],
"attributes": {
"tags": [
"applicationinsights:TagResource",
"applicationinsights:UntagResource"
]
},
"destroy": [
"applicationinsights:DeleteApplication"
],
"modify": [
"applicationinsights:UpdateApplication"
],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"apply": [
"resource-groups:CreateGroup",
"resource-groups:GetGroup",
"resource-groups:GetGroupQuery",
"resource-groups:GetTags",
"resource-groups:DeleteGroup"
],
"attributes": {
"tags": [
"resource-groups:Untag",
"resource-groups:Tag"
]
},
"destroy": [
"resource-groups:DeleteGroup"
],
"modify": [
"resource:UpdateGroup"
],
"plan": []
}
]
15 changes: 15 additions & 0 deletions terraform/aws/backup/aws_applicationinsights_application.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_applicationinsights_application" "pike" {
resource_group_name = aws_resourcegroups_group.pike.name
auto_config_enabled = true
auto_create = true
ops_center_enabled = true
ops_item_sns_topic_arn = data.aws_sns_topic.pike.arn
tags = {
pike = "permissions"
}
}


data "aws_sns_topic" "pike" {
name = "pike"
}
24 changes: 24 additions & 0 deletions terraform/aws/backup/aws_resourcegroups_group.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "aws_resourcegroups_group" "pike" {
name = "pike"

resource_query {
query = <<JSON
{
"ResourceTypeFilters": [
"AWS::EC2::Instance"
],
"TagFilters": [
{
"Key": "Stage",
"Values": [
"Test"
]
}
]
}
JSON
}
tags = {
pike = "permissions"
}
}
26 changes: 19 additions & 7 deletions terraform/aws/role/aws_iam_policy.basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@ resource "aws_iam_policy" "basic" {
"Effect" : "Allow",
"Action" : [
"ec2:DescribeAccountAttributes",
"kms:DescribeKey",
"SNS:ListTopics",

#data role
"iam:GetRole",
"resource-groups:CreateGroup",
"resource-groups:GetGroup",
"resource-groups:GetGroupQuery",
"resource-groups:GetTags",
"resource-groups:DeleteGroup",
"resource-groups:Untag",
"resource-groups:Tag",
"resource:UpdateGroup",

#grant
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant"
"applicationinsights:CreateApplication",
"applicationinsights:TagResource",
"applicationinsights:UntagResource",
"iam:CreateServiceLinkedRole",
"logs:DescribeLogGroups",
"applicationinsights:DescribeApplication",
"applicationinsights:ListTagsForResource",
"applicationinsights:DeleteApplication",

"applicationinsights:UpdateApplication"
],
"Resource" : "*",
}
Expand Down
1 change: 0 additions & 1 deletion todo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# todo

./resource.ps1 aws_acm_certificate -type data
./resource.ps1 aws_applicationinsights_application
./resource.ps1 aws_appmesh_gateway_route
./resource.ps1 aws_appmesh_mesh
./resource.ps1 aws_appmesh_mesh -type data
Expand Down

0 comments on commit dccaebe

Please sign in to comment.