lib/aws_recon/collectors/ec2.rb in aws_recon-0.5.0 vs lib/aws_recon/collectors/ec2.rb in aws_recon-0.5.1
- old
+ new
@@ -27,11 +27,11 @@
log(response.context.operation_name)
struct = OpenStruct.new
struct.attributes = response.account_attributes.map(&:to_h)
struct.type = 'account'
- struct.arn = "arn:aws:ec2::#{@account}/account_attributes"
+ struct.arn = "arn:aws:ec2::#{@account}:attributes/account_attributes"
resources.push(struct.to_h)
end
end
@@ -43,11 +43,11 @@
@client.get_ebs_encryption_by_default.each do |response|
log(response.context.operation_name)
struct = OpenStruct.new(response.to_h)
struct.type = 'ebs_encryption_settings'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/ebs_encryption_settings"
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:settings/ebs_encryption_settings"
resources.push(struct.to_h)
end
#
@@ -62,11 +62,11 @@
# instances
reservation.instances.each do |instance|
struct = OpenStruct.new(instance.to_h)
struct.type = 'instance'
- struct.arn = instance.instance_id # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:instance/#{instance.instance_id}" # no true ARN
struct.reservation_id = reservation.reservation_id
# collect instance user_data
if @options.collect_user_data
user_data_raw = @client.describe_instance_attribute({
@@ -94,11 +94,11 @@
log(response.context.operation_name, page)
response.vpcs.each do |vpc|
struct = OpenStruct.new(vpc.to_h)
struct.type = 'vpc'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{vpc.vpc_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:vpc/#{vpc.vpc_id}" # no true ARN
struct.flow_logs = @client
.describe_flow_logs({ filter: [{ name: 'resource-id', values: [vpc.vpc_id] }] })
.flow_logs.first.to_h
resources.push(struct.to_h)
@@ -112,11 +112,11 @@
log(response.context.operation_name, page)
response.security_groups.each do |security_group|
struct = OpenStruct.new(security_group.to_h)
struct.type = 'security_group'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{security_group.group_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:security_group/#{security_group.group_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -127,11 +127,11 @@
log(response.context.operation_name, page)
response.network_interfaces.each do |network_interface|
struct = OpenStruct.new(network_interface.to_h)
struct.type = 'network_interface'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{network_interface.network_interface_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:network_interface/#{network_interface.network_interface_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -142,11 +142,11 @@
log(response.context.operation_name, page)
response.network_acls.each do |network_acl|
struct = OpenStruct.new(network_acl.to_h)
struct.type = 'network_acl'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{network_acl.network_acl_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:network_acl/#{network_acl.network_acl_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -157,11 +157,11 @@
log(response.context.operation_name, page)
response.subnets.each do |subnet|
struct = OpenStruct.new(subnet.to_h)
struct.type = 'subnet'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{subnet.subnet_arn}" # no true ARN
+ struct.arn = subnet.subnet_arn
resources.push(struct.to_h)
end
end
@@ -172,11 +172,11 @@
log(response.context.operation_name, page)
response.addresses.each do |address|
struct = OpenStruct.new(address.to_h)
struct.type = 'eip_address'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{address.allocation_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:eip_address/#{address.allocation_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -187,11 +187,11 @@
log(response.context.operation_name, page)
response.nat_gateways.each do |gateway|
struct = OpenStruct.new(gateway.to_h)
struct.type = 'nat_gateway'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{gateway.nat_gateway_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:nat_gateway/#{gateway.nat_gateway_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -202,11 +202,11 @@
log(response.context.operation_name, page)
response.internet_gateways.each do |gateway|
struct = OpenStruct.new(gateway.to_h)
struct.type = 'internet_gateway'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{gateway.internet_gateway_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:internet_gateway/#{gateway.internet_gateway_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -217,11 +217,11 @@
log(response.context.operation_name, page)
response.route_tables.each do |table|
struct = OpenStruct.new(table.to_h)
struct.type = 'route_table'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{table.route_table_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:route_table/#{table.route_table_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -232,11 +232,11 @@
log(response.context.operation_name, page)
response.images.each do |image|
struct = OpenStruct.new(image.to_h)
struct.type = 'image'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{image.image_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:image/#{image.image_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -247,11 +247,11 @@
log(response.context.operation_name, page)
response.snapshots.each do |snapshot|
struct = OpenStruct.new(snapshot.to_h)
struct.type = 'snapshot'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{snapshot.snapshot_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:snapshot/#{snapshot.snapshot_id}" # no true ARN
struct.create_volume_permissions = @client.describe_snapshot_attribute({
attribute: 'createVolumePermission',
snapshot_id: snapshot.snapshot_id
}).create_volume_permissions.map(&:to_h)
@@ -266,11 +266,11 @@
log(response.context.operation_name, page)
response.flow_logs.each do |flow_log|
struct = OpenStruct.new(flow_log.to_h)
struct.type = 'flow_log'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{flow_log.flow_log_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:flow_log/#{flow_log.flow_log_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -281,11 +281,11 @@
log(response.context.operation_name, page)
response.volumes.each do |volume|
struct = OpenStruct.new(volume.to_h)
struct.type = 'volume'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{volume.volume_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:volume/#{volume.volume_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -296,11 +296,11 @@
log(response.context.operation_name, page)
response.vpn_gateways.each do |gateway|
struct = OpenStruct.new(gateway.to_h)
struct.type = 'vpn_gateway'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{gateway.vpn_gateway_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:vpn_gateway/#{gateway.vpn_gateway_id}" # no true ARN
resources.push(struct.to_h)
end
end
@@ -311,10 +311,10 @@
log(response.context.operation_name, page)
response.vpc_peering_connections.each do |peer|
struct = OpenStruct.new(peer.to_h)
struct.type = 'peering_connection'
- struct.arn = "arn:aws:ec2:#{@region}:#{@account}/#{peer.vpc_peering_connection_id}" # no true ARN
+ struct.arn = "arn:aws:ec2:#{@region}:#{@account}:peering_connection/#{peer.vpc_peering_connection_id}" # no true ARN
resources.push(struct.to_h)
end
end
end