Skip to content

Commit

Permalink
snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Dec 17, 2022
1 parent 2a84301 commit 9fde4c7
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .run/scan aws.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</EXTENSION>
<kind value="PACKAGE" />
<kind value="DIRECTORY" />
<package value="github.com/jameswoolfenden/pike" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
Expand Down
2 changes: 2 additions & 0 deletions src/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ func GetAWSResourcePermissions(result ResourceV2) ([]string, error) {
"aws_backup_vault_lock_configuration": awsBackupVaultLockConfiguration,
"aws_backup_vault_notifications": awsBackupVaultNotification,
"aws_backup_vault_policy": awsBackupVaultPolicy,
"aws_ebs_snapshot": awsEbsSnapshot,
"aws_ebs_snapshot_copy": awsEbsSnapshotCopy,
}

var Permissions []string
Expand Down
4 changes: 4 additions & 0 deletions src/aws_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func GetAWSDataPermissions(result ResourceV2) ([]string, error) {
"aws_backup_plan": dataBackupPlan,
"aws_backup_report_plan": dataBackupReportPlan,
"aws_backup_selection": dataBackupSelection,
"aws_ebs_snapshot": dataAwsEbsSnapshot,
"aws_ebs_snapshot_ids": dataAwsEbsSnapshotIds,
"aws_ebs_volume": dataAwsEbsVolume,
"aws_ebs_volumes": dataAwsEbsVolumes,
}

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 @@ -975,3 +975,9 @@ var awsBackupVaultNotification []byte

//go:embed mapping/aws/resource/backup/aws_backup_vault_policy.json
var awsBackupVaultPolicy []byte

//go:embed mapping/aws/resource/ec2/aws_ebs_snapshot.json
var awsEbsSnapshot []byte

//go:embed mapping/aws/resource/ec2/aws_ebs_snapshot_copy.json
var awsEbsSnapshotCopy []byte
12 changes: 12 additions & 0 deletions src/files_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ var dataBackupReportPlan []byte

//go:embed mapping/aws/data/backup/aws_backup_selection.json
var dataBackupSelection []byte

//go:embed mapping/aws/data/ec2/aws_ebs_snapshot.json
var dataAwsEbsSnapshot []byte

//go:embed mapping/aws/data/ec2/aws_ebs_snapshot_ids.json
var dataAwsEbsSnapshotIds []byte

//go:embed mapping/aws/data/ec2/aws_ebs_volume.json
var dataAwsEbsVolume []byte

//go:embed mapping/aws/data/ec2/aws_ebs_volumes.json
var dataAwsEbsVolumes []byte
13 changes: 13 additions & 0 deletions src/mapping/aws/data/ec2/aws_ebs_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"ec2:DescribeSnapshots"
]
}
]
13 changes: 13 additions & 0 deletions src/mapping/aws/data/ec2/aws_ebs_snapshot_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"ec2:DescribeSnapshots"
]
}
]
13 changes: 13 additions & 0 deletions src/mapping/aws/data/ec2/aws_ebs_volume.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"ec2:DescribeVolumes"
]
}
]
13 changes: 13 additions & 0 deletions src/mapping/aws/data/ec2/aws_ebs_volumes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"ec2:DescribeVolumes"
]
}
]
19 changes: 19 additions & 0 deletions src/mapping/aws/resource/ec2/aws_ebs_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"apply": [
"ec2:CreateSnapshot",
"ec2:DescribeVolumes",
"ec2:DescribeSnapshots",
"ec2:DeleteSnapshot"
],
"attributes": {
"tags": [
"ec2:DeleteTags",
"ec2:CreateTags"
]
},
"destroy": [],
"modify": [],
"plan": []
}
]
21 changes: 21 additions & 0 deletions src/mapping/aws/resource/ec2/aws_ebs_snapshot_copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"apply": [
"ec2:DescribeAccountAttributes",
"ec2:DescribeSnapshots",
"ec2:CopySnapshot",
"ec2:DeleteSnapshot"
],
"attributes": {
"tags": [
"ec2:DeleteTags",
"ec2:CreateTags"
]
},
"destroy": [
"ec2:DeleteSnapshot"
],
"modify": [],
"plan": []
}
]
10 changes: 10 additions & 0 deletions terraform/aws/backup/aws_ebs_snapshot.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "aws_ebs_snapshot" "pike" {
volume_id = data.aws_ebs_volume.pike.id
description = "pike"
storage_tier = "standard"

tags = {
pike = "permissions"
and = "another"
}
}
7 changes: 7 additions & 0 deletions terraform/aws/backup/aws_ebs_snapshot_copy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "aws_ebs_snapshot_copy" "pike" {
source_region = "eu-west-1"
source_snapshot_id = "snap-08f14c31fd87f4ab7"
tags = {
pike = "permission"
}
}
7 changes: 7 additions & 0 deletions terraform/aws/backup/data.aws_ebs_snapshot.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "aws_ebs_snapshot" "pike" {
most_recent = true
}

output "snap" {
value = data.aws_ebs_snapshot.pike
}
5 changes: 5 additions & 0 deletions terraform/aws/backup/data.aws_ebs_snapshot_ids.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "aws_ebs_snapshot_ids" "pike" {}

output "snaps" {
value = data.aws_ebs_snapshot_ids.pike
}
9 changes: 9 additions & 0 deletions terraform/aws/backup/data.aws_ebs_volume.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data "aws_ebs_volume" "pike" {
most_recent = true

filter {
name = "volume-type"
values = ["gp2"]
}

}
5 changes: 5 additions & 0 deletions terraform/aws/backup/data.aws_ebs_volumes.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "aws_ebs_volumes" "pike" {}

output "volumes" {
value = data.aws_ebs_volumes.pike
}
13 changes: 6 additions & 7 deletions terraform/aws/role/aws_iam_policy.basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ resource "aws_iam_policy" "basic" {
"Effect" : "Allow",
"Action" : [
"ec2:DescribeAccountAttributes",
"Backup:CreateBackupPlan",
"Backup:GetBackupPlan",
"Backup:UntagResource",
"Backup:TagResource",
"Backup:ListTags",
"Backup:DeleteBackupPlan",
"Backup:UpdateBackupPlan",
"ec2:DescribeSnapshots",
"ec2:CopySnapshot",
"ec2:DeleteSnapshot",

"ec2:DeleteTags",
"ec2:CreateTags",

],
"Resource" : "*",
Expand Down
13 changes: 5 additions & 8 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,8 @@
./resource.ps1 aws_cloudfront_response_headers_policy

snapshots
aws_ebs_snapshot
aws_ebs_snapshot_copy
aws_ebs_snapshot_import
aws_snapshot_create_volume_permission
aws_ebs_snapshot -type data
aws_ebs_snapshot_ids -type data
aws_db_snapshot_copy
aws_redshiftserverless_snapshot

./resource.ps1 aws_ebs_snapshot_import
./resource.ps1 aws_snapshot_create_volume_permission
./resource.ps1 aws_db_snapshot_copy
./resource.ps1 aws_redshiftserverless_snapshot

0 comments on commit 9fde4c7

Please sign in to comment.