geoengineer 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +8 -6
- data/lib/geoengineer.rb +2 -0
- data/lib/geoengineer/cli/geo_cli.rb +1 -4
- data/lib/geoengineer/cli/terraform_commands.rb +4 -2
- data/lib/geoengineer/environment.rb +14 -1
- data/lib/geoengineer/provider.rb +38 -0
- data/lib/geoengineer/resource.rb +29 -15
- data/lib/geoengineer/resources/api_gateway/helpers.rb +107 -0
- data/lib/geoengineer/resources/aws_alb.rb +39 -0
- data/lib/geoengineer/resources/aws_alb_listener.rb +39 -0
- data/lib/geoengineer/resources/aws_alb_listener_rule.rb +42 -0
- data/lib/geoengineer/resources/aws_alb_target_group.rb +30 -0
- data/lib/geoengineer/resources/aws_api_gateway_account.rb +18 -0
- data/lib/geoengineer/resources/aws_api_gateway_api_key.rb +20 -0
- data/lib/geoengineer/resources/aws_api_gateway_authorizer.rb +20 -0
- data/lib/geoengineer/resources/aws_api_gateway_base_path_mapping.rb +20 -0
- data/lib/geoengineer/resources/aws_api_gateway_client_certificate.rb +24 -0
- data/lib/geoengineer/resources/aws_api_gateway_deployment.rb +65 -0
- data/lib/geoengineer/resources/aws_api_gateway_domain_name.rb +27 -0
- data/lib/geoengineer/resources/aws_api_gateway_integration.rb +58 -0
- data/lib/geoengineer/resources/aws_api_gateway_integration_response.rb +68 -0
- data/lib/geoengineer/resources/aws_api_gateway_method.rb +59 -0
- data/lib/geoengineer/resources/aws_api_gateway_method_response.rb +69 -0
- data/lib/geoengineer/resources/aws_api_gateway_model.rb +19 -0
- data/lib/geoengineer/resources/aws_api_gateway_resource.rb +47 -0
- data/lib/geoengineer/resources/aws_api_gateway_rest_api.rb +79 -0
- data/lib/geoengineer/resources/aws_api_gateway_usage_plan.rb +27 -0
- data/lib/geoengineer/resources/aws_cloudfront_distribution.rb +25 -0
- data/lib/geoengineer/resources/aws_cloudtrail.rb +2 -2
- data/lib/geoengineer/resources/aws_cloudwatch_event_rule.rb +12 -3
- data/lib/geoengineer/resources/aws_cloudwatch_event_target.rb +2 -2
- data/lib/geoengineer/resources/aws_cloudwatch_metric_alarm.rb +10 -8
- data/lib/geoengineer/resources/aws_customer_gateway.rb +4 -2
- data/lib/geoengineer/resources/aws_db_instance.rb +2 -2
- data/lib/geoengineer/resources/aws_db_parameter_group.rb +4 -2
- data/lib/geoengineer/resources/aws_dynamodb_table.rb +2 -2
- data/lib/geoengineer/resources/aws_eip.rb +2 -2
- data/lib/geoengineer/resources/aws_elasticache_cluster.rb +2 -2
- data/lib/geoengineer/resources/aws_elasticache_parameter_group.rb +2 -2
- data/lib/geoengineer/resources/aws_elasticache_replication_group.rb +2 -2
- data/lib/geoengineer/resources/aws_elasticache_subnet_group.rb +2 -2
- data/lib/geoengineer/resources/aws_elasticsearch_domain.rb +2 -2
- data/lib/geoengineer/resources/aws_elb.rb +4 -2
- data/lib/geoengineer/resources/aws_iam_account_password_policy.rb +2 -1
- data/lib/geoengineer/resources/aws_iam_group.rb +2 -2
- data/lib/geoengineer/resources/aws_iam_group_membership.rb +1 -1
- data/lib/geoengineer/resources/aws_iam_instance_profile.rb +3 -3
- data/lib/geoengineer/resources/aws_iam_policy.rb +6 -4
- data/lib/geoengineer/resources/aws_iam_policy_attachment.rb +1 -1
- data/lib/geoengineer/resources/aws_iam_role.rb +2 -2
- data/lib/geoengineer/resources/aws_iam_role_policy.rb +10 -9
- data/lib/geoengineer/resources/aws_iam_user.rb +4 -4
- data/lib/geoengineer/resources/aws_instance.rb +3 -3
- data/lib/geoengineer/resources/aws_internet_gateway.rb +3 -2
- data/lib/geoengineer/resources/aws_kinesis_stream.rb +4 -4
- data/lib/geoengineer/resources/aws_kms_key.rb +5 -3
- data/lib/geoengineer/resources/aws_lambda_alias.rb +7 -7
- data/lib/geoengineer/resources/aws_lambda_event_source_mapping.rb +2 -2
- data/lib/geoengineer/resources/aws_lambda_function.rb +2 -2
- data/lib/geoengineer/resources/aws_lambda_permission.rb +9 -8
- data/lib/geoengineer/resources/aws_lb_cookie_stickiness_policy.rb +47 -0
- data/lib/geoengineer/resources/aws_load_balancer_backend_server_policy.rb +2 -2
- data/lib/geoengineer/resources/aws_load_balancer_policy.rb +5 -5
- data/lib/geoengineer/resources/aws_main_route_table_association.rb +2 -2
- data/lib/geoengineer/resources/aws_nat_gateway.rb +2 -2
- data/lib/geoengineer/resources/aws_network_acl.rb +2 -2
- data/lib/geoengineer/resources/aws_network_acl_rule.rb +2 -2
- data/lib/geoengineer/resources/aws_proxy_protocol_policy.rb +1 -1
- data/lib/geoengineer/resources/aws_redshift_cluster.rb +2 -2
- data/lib/geoengineer/resources/aws_route.rb +2 -2
- data/lib/geoengineer/resources/aws_route53_record.rb +6 -6
- data/lib/geoengineer/resources/aws_route53_zone.rb +2 -2
- data/lib/geoengineer/resources/aws_route_table.rb +2 -2
- data/lib/geoengineer/resources/aws_route_table_association.rb +2 -2
- data/lib/geoengineer/resources/aws_s3_bucket.rb +2 -2
- data/lib/geoengineer/resources/aws_s3_bucket_notification.rb +38 -0
- data/lib/geoengineer/resources/aws_security_group.rb +2 -2
- data/lib/geoengineer/resources/aws_ses_receipt_rule.rb +2 -2
- data/lib/geoengineer/resources/aws_ses_receipt_rule_set.rb +2 -2
- data/lib/geoengineer/resources/aws_sns_topic.rb +2 -2
- data/lib/geoengineer/resources/aws_sns_topic_subscription.rb +5 -5
- data/lib/geoengineer/resources/aws_sqs_queue.rb +2 -2
- data/lib/geoengineer/resources/aws_subnet.rb +2 -2
- data/lib/geoengineer/resources/aws_vpc.rb +2 -2
- data/lib/geoengineer/resources/aws_vpc_dhcp_options.rb +2 -2
- data/lib/geoengineer/resources/aws_vpc_dhcp_options_association.rb +2 -2
- data/lib/geoengineer/resources/aws_vpc_endpoint.rb +2 -2
- data/lib/geoengineer/resources/aws_vpc_peering_connection.rb +2 -2
- data/lib/geoengineer/resources/aws_vpn_connection.rb +3 -2
- data/lib/geoengineer/resources/aws_vpn_connection_route.rb +2 -2
- data/lib/geoengineer/resources/aws_vpn_gateway.rb +2 -2
- data/lib/geoengineer/resources/aws_vpn_gateway_attachment.rb +2 -2
- data/lib/geoengineer/template.rb +3 -1
- data/lib/geoengineer/templates/json_rest_api.rb +197 -0
- data/lib/geoengineer/utils/aws_clients.rb +129 -38
- data/lib/geoengineer/utils/has_templates.rb +1 -1
- data/lib/geoengineer/version.rb +1 -1
- data/spec/environment_spec.rb +1 -1
- data/spec/resource_spec.rb +24 -10
- data/spec/resources/aws_alb_listener_rule_spec.rb +45 -0
- data/spec/resources/aws_alb_listener_spec.rb +33 -0
- data/spec/resources/aws_alb_spec.rb +33 -0
- data/spec/resources/aws_alb_target_group_spec.rb +35 -0
- data/spec/resources/aws_api_gateway_account_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_api_key_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_authorizer_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_base_path_mapping_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_client_certificate_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_deployment_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_domain_name_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_integration_response_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_integration_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_method_response_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_method_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_model_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_resource_spec.rb +6 -0
- data/spec/resources/aws_api_gateway_rest_api_spec.rb +6 -0
- data/spec/resources/aws_cloudfront_distribution_spec.rb +50 -0
- data/spec/resources/aws_cloudtrail_spec.rb +3 -3
- data/spec/resources/aws_cloudwatch_event_rule_spec.rb +3 -3
- data/spec/resources/aws_cloudwatch_event_target_spec.rb +4 -6
- data/spec/resources/aws_cloudwatch_metric_alarm_spec.rb +3 -6
- data/spec/resources/aws_customer_gateway_spec.rb +4 -3
- data/spec/resources/aws_db_instance_spec.rb +3 -3
- data/spec/resources/aws_db_parameter_group_spec.rb +3 -3
- data/spec/resources/aws_dynamodb_table_spec.rb +3 -3
- data/spec/resources/aws_eip_spec.rb +3 -3
- data/spec/resources/aws_elasticache_replication_group_spec.rb +3 -6
- data/spec/resources/aws_elasticache_subnet_group_spec.rb +4 -6
- data/spec/resources/aws_elasticcache_cluster_spec.rb +3 -3
- data/spec/resources/aws_elasticcache_parameter_group_spec.rb +3 -6
- data/spec/resources/aws_elasticsearch_domain_spec.rb +3 -3
- data/spec/resources/aws_elb_spec.rb +3 -3
- data/spec/resources/aws_iam_account_password_policy_spec.rb +2 -6
- data/spec/resources/aws_iam_group_membership_spec.rb +2 -6
- data/spec/resources/aws_iam_group_spec.rb +3 -3
- data/spec/resources/aws_iam_instance_profile_spec.rb +3 -6
- data/spec/resources/aws_iam_policy_attachment_spec.rb +2 -6
- data/spec/resources/aws_iam_policy_spec.rb +3 -5
- data/spec/resources/aws_iam_role_spec.rb +3 -4
- data/spec/resources/aws_iam_rule_policy_spec.rb +2 -5
- data/spec/resources/aws_iam_user_spec.rb +3 -4
- data/spec/resources/aws_instance_spec.rb +3 -3
- data/spec/resources/aws_internet_gateway_spec.rb +3 -3
- data/spec/resources/aws_kinesis_stream_spec.rb +3 -4
- data/spec/resources/aws_kms_key_spec.rb +3 -3
- data/spec/resources/aws_lambda_alias_spec.rb +2 -3
- data/spec/resources/aws_lambda_event_source_mapping_spec.rb +2 -5
- data/spec/resources/aws_lambda_function_spec.rb +3 -4
- data/spec/resources/aws_lambda_permission_spec.rb +1 -1
- data/spec/resources/aws_lb_cookie_stickiness_policy_spec.rb +38 -0
- data/spec/resources/aws_load_balancer_backend_server_policy_spec.rb +2 -3
- data/spec/resources/aws_load_balancer_policy_spec.rb +3 -4
- data/spec/resources/aws_main_route_table_association_spec.rb +2 -5
- data/spec/resources/aws_nat_gateway_spec.rb +3 -4
- data/spec/resources/aws_network_acl_rule_spec.rb +2 -3
- data/spec/resources/aws_network_acl_spec.rb +3 -3
- data/spec/resources/aws_proxy_protocol_policy_spec.rb +2 -2
- data/spec/resources/aws_redshift_cluster_spec.rb +3 -3
- data/spec/resources/aws_route53_record_spec.rb +3 -4
- data/spec/resources/aws_route53_zone_spec.rb +3 -4
- data/spec/resources/aws_route_spec.rb +3 -6
- data/spec/resources/aws_route_table_association_spec.rb +4 -6
- data/spec/resources/aws_route_table_spec.rb +3 -3
- data/spec/resources/aws_s3_bucket_notification_spec.rb +4 -0
- data/spec/resources/aws_s3_bucket_spec.rb +3 -3
- data/spec/resources/aws_security_group_spec.rb +5 -5
- data/spec/resources/aws_ses_receipt_rule_set_spec.rb +3 -4
- data/spec/resources/aws_ses_receipt_rule_spec.rb +3 -4
- data/spec/resources/aws_sns_topic_spec.rb +10 -6
- data/spec/resources/aws_sns_topic_subscription_spec.rb +8 -7
- data/spec/resources/aws_sqs_queue_spec.rb +3 -3
- data/spec/resources/aws_subnet_spec.rb +3 -3
- data/spec/resources/aws_vpc_dhcp_options_association_spec.rb +3 -6
- data/spec/resources/aws_vpc_dhcp_options_spec.rb +3 -3
- data/spec/resources/aws_vpc_endpoint_spec.rb +3 -6
- data/spec/resources/aws_vpc_peering_connection_spec.rb +4 -6
- data/spec/resources/aws_vpc_spec.rb +3 -3
- data/spec/resources/aws_vpn_connection_route_spec.rb +3 -6
- data/spec/resources/aws_vpn_connection_spec.rb +3 -3
- data/spec/resources/aws_vpn_gateway_attachment_spec.rb +4 -6
- data/spec/resources/aws_vpn_gateway_spec.rb +3 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/normalize_indent.rb +12 -0
- metadata +92 -22
- metadata.gz.sig +0 -0
@@ -35,7 +35,7 @@ class GeoEngineer::Resources::AwsIamGroupMembership < GeoEngineer::Resource
|
|
35
35
|
return {} unless _group
|
36
36
|
return {} unless _group.remote_resource
|
37
37
|
|
38
|
-
users = AwsClients.iam.get_group({ group_name: _group.name })['users']
|
38
|
+
users = AwsClients.iam(provider).get_group({ group_name: _group.name })['users']
|
39
39
|
build_remote_resource_params(users)
|
40
40
|
end
|
41
41
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# {https://www.terraform.io/docs/providers/aws/r/iam_instance_profile.html Terraform Docs}
|
5
5
|
########################################################################
|
6
6
|
class GeoEngineer::Resources::AwsIamInstanceProfile < GeoEngineer::Resource
|
7
|
-
validate -> { validate_required_attributes([:name, :
|
7
|
+
validate -> { validate_required_attributes([:name, :role]) }
|
8
8
|
|
9
9
|
before :validation, -> { policy_arn _policy.to_ref(:arn) if _policy }
|
10
10
|
|
@@ -15,8 +15,8 @@ class GeoEngineer::Resources::AwsIamInstanceProfile < GeoEngineer::Resource
|
|
15
15
|
false
|
16
16
|
end
|
17
17
|
|
18
|
-
def self._fetch_remote_resources
|
19
|
-
profiles = AwsClients.iam.list_instance_profiles['instance_profiles'].map(&:to_h)
|
18
|
+
def self._fetch_remote_resources(provider)
|
19
|
+
profiles = AwsClients.iam(provider).list_instance_profiles['instance_profiles'].map(&:to_h)
|
20
20
|
profiles.map do |p|
|
21
21
|
{
|
22
22
|
name: p[:instance_profile_name],
|
@@ -44,12 +44,14 @@ class GeoEngineer::Resources::AwsIamPolicy < GeoEngineer::Resource
|
|
44
44
|
URI.decode(response.policy_version.document)
|
45
45
|
end
|
46
46
|
|
47
|
-
def self._all_remote_policies
|
48
|
-
AwsClients.iam
|
47
|
+
def self._all_remote_policies(provider)
|
48
|
+
AwsClients.iam(provider)
|
49
|
+
.list_policies({ scope: "Local" })
|
50
|
+
.each.map(&:policies).flatten.map(&:to_h)
|
49
51
|
end
|
50
52
|
|
51
|
-
def self._fetch_remote_resources
|
52
|
-
_all_remote_policies.map(&:to_h).map do |policy|
|
53
|
+
def self._fetch_remote_resources(provider)
|
54
|
+
_all_remote_policies(provider).map(&:to_h).map do |policy|
|
53
55
|
{
|
54
56
|
_terraform_id: policy[:arn],
|
55
57
|
_geo_id: policy[:policy_name],
|
@@ -77,7 +77,7 @@ class GeoEngineer::Resources::AwsIamPolicyAttachment < GeoEngineer::Resource
|
|
77
77
|
return {} unless _policy.remote_resource
|
78
78
|
|
79
79
|
arn = _policy.remote_resource._terraform_id
|
80
|
-
entities = AwsClients.iam.list_entities_for_policy({ policy_arn: arn })
|
80
|
+
entities = AwsClients.iam(provider).list_entities_for_policy({ policy_arn: arn })
|
81
81
|
build_remote_resource_params(arn, entities)
|
82
82
|
end
|
83
83
|
|
@@ -33,8 +33,8 @@ class GeoEngineer::Resources::AwsIamRole < GeoEngineer::Resource
|
|
33
33
|
false
|
34
34
|
end
|
35
35
|
|
36
|
-
def self._fetch_remote_resources
|
37
|
-
roles = AwsClients.iam.list_roles['roles'].map(&:to_h)
|
36
|
+
def self._fetch_remote_resources(provider)
|
37
|
+
roles = AwsClients.iam(provider).list_roles['roles'].map(&:to_h)
|
38
38
|
roles.map do |r|
|
39
39
|
r.merge({ name: r[:role_name],
|
40
40
|
_geo_id: r[:role_name],
|
@@ -32,32 +32,33 @@ class GeoEngineer::Resources::AwsIamRolePolicy < GeoEngineer::Resource
|
|
32
32
|
_json_file(:policy, path, binding_obj)
|
33
33
|
end
|
34
34
|
|
35
|
-
def self._fetch_remote_resources
|
35
|
+
def self._fetch_remote_resources(provider)
|
36
36
|
AwsClients
|
37
|
-
.iam
|
37
|
+
.iam(provider)
|
38
38
|
.list_roles
|
39
39
|
.roles
|
40
40
|
.map(&:to_h)
|
41
|
-
.map { |role| _get_role_policies(role) }
|
41
|
+
.map { |role| _get_role_policies(provider, role) }
|
42
42
|
.flatten
|
43
43
|
.compact
|
44
|
-
.map { |role_policy| _get_policy(role_policy) }
|
44
|
+
.map { |role_policy| _get_policy(provider, role_policy) }
|
45
45
|
end
|
46
46
|
|
47
|
-
def self._get_role_policies(role)
|
47
|
+
def self._get_role_policies(provider, role)
|
48
48
|
AwsClients
|
49
|
-
.iam
|
49
|
+
.iam(provider)
|
50
50
|
.list_role_policies({ role_name: role[:role_name] })
|
51
51
|
.map(&:policy_names)
|
52
52
|
.flatten
|
53
53
|
.map { |policy| { role_name: role[:role_name], policy_name: policy } }
|
54
54
|
end
|
55
55
|
|
56
|
-
def self._get_policy(role_policy)
|
56
|
+
def self._get_policy(provider, role_policy)
|
57
57
|
AwsClients
|
58
|
-
.iam
|
58
|
+
.iam(provider)
|
59
59
|
.get_role_policy(role_policy)
|
60
60
|
.to_h
|
61
|
-
.merge({ _terraform_id: "#{role_policy[:role_name]}:#{role_policy[:policy_name]}"
|
61
|
+
.merge({ _terraform_id: "#{role_policy[:role_name]}:#{role_policy[:policy_name]}",
|
62
|
+
_geo_id: "#{role_policy[:role_name]}:#{role_policy[:policy_name]}" })
|
62
63
|
end
|
63
64
|
end
|
@@ -26,12 +26,12 @@ class GeoEngineer::Resources::AwsIamUser < GeoEngineer::Resource
|
|
26
26
|
false
|
27
27
|
end
|
28
28
|
|
29
|
-
def self._all_remote_users
|
30
|
-
AwsClients.iam.list_users.each.map(&:users).flatten.map(&:to_h)
|
29
|
+
def self._all_remote_users(provider)
|
30
|
+
AwsClients.iam(provider).list_users.each.map(&:users).flatten.map(&:to_h)
|
31
31
|
end
|
32
32
|
|
33
|
-
def self._fetch_remote_resources
|
34
|
-
_all_remote_users.map do |user|
|
33
|
+
def self._fetch_remote_resources(provider)
|
34
|
+
_all_remote_users(provider).map do |user|
|
35
35
|
{
|
36
36
|
_terraform_id: user[:user_name],
|
37
37
|
_geo_id: user[:user_name],
|
@@ -10,12 +10,12 @@ class GeoEngineer::Resources::AwsInstance < GeoEngineer::Resource
|
|
10
10
|
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
11
11
|
after :initialize, -> { _geo_id -> { NullObject.maybe(tags)[:Name] } }
|
12
12
|
|
13
|
-
def self._all_remote_instances
|
13
|
+
def self._all_remote_instances(provider)
|
14
14
|
AwsClients.ec2.describe_instances.reservations.map(&:instances).flatten.map(&:to_h)
|
15
15
|
end
|
16
16
|
|
17
|
-
def self._fetch_remote_resources
|
18
|
-
_all_remote_instances.map do |instance|
|
17
|
+
def self._fetch_remote_resources(provider)
|
18
|
+
_all_remote_instances(provider).map do |instance|
|
19
19
|
instance.merge(
|
20
20
|
{
|
21
21
|
_terraform_id: instance[:instance_id],
|
@@ -10,8 +10,9 @@ class GeoEngineer::Resources::AwsInternetGateway < GeoEngineer::Resource
|
|
10
10
|
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
11
11
|
after :initialize, -> { _geo_id -> { NullObject.maybe(tags)[:Name] } }
|
12
12
|
|
13
|
-
def self._fetch_remote_resources
|
14
|
-
AwsClients.ec2
|
13
|
+
def self._fetch_remote_resources(provider)
|
14
|
+
AwsClients.ec2(provider)
|
15
|
+
.describe_internet_gateways['internet_gateways'].map(&:to_h).map do |gateway|
|
15
16
|
gateway.merge(
|
16
17
|
{
|
17
18
|
_terraform_id: gateway[:internet_gateway_id],
|
@@ -19,9 +19,9 @@ class GeoEngineer::Resources::AwsKinesisStream < GeoEngineer::Resource
|
|
19
19
|
tfstate
|
20
20
|
end
|
21
21
|
|
22
|
-
def self._all_streams
|
22
|
+
def self._all_streams(provider)
|
23
23
|
streams = []
|
24
|
-
AwsClients.kinesis.list_streams[:stream_names].each do |stream_name|
|
24
|
+
AwsClients.kinesis(provider).list_streams[:stream_names].each do |stream_name|
|
25
25
|
AwsClients.kinesis.describe_stream({ stream_name: stream_name }).map(&:to_h).map do |stream|
|
26
26
|
streams << stream[:stream_description]
|
27
27
|
end
|
@@ -29,8 +29,8 @@ class GeoEngineer::Resources::AwsKinesisStream < GeoEngineer::Resource
|
|
29
29
|
streams
|
30
30
|
end
|
31
31
|
|
32
|
-
def self._fetch_remote_resources
|
33
|
-
self._all_streams.map do |stream|
|
32
|
+
def self._fetch_remote_resources(provider)
|
33
|
+
self._all_streams(provider).map do |stream|
|
34
34
|
stream.merge({
|
35
35
|
_terraform_id: stream[:stream_arn],
|
36
36
|
_geo_id: stream[:stream_name]
|
@@ -8,14 +8,16 @@ class GeoEngineer::Resources::AwsKmsKey < GeoEngineer::Resource
|
|
8
8
|
|
9
9
|
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
10
10
|
after :initialize, -> { _geo_id -> { description } }
|
11
|
+
after :initialize, -> { _arn -> { NullObject.maybe(remote_resource)._arn } }
|
11
12
|
|
12
|
-
def self._fetch_remote_resources
|
13
|
-
keys = AwsClients.kms.list_keys[:keys].map do |i|
|
14
|
-
AwsClients.kms.describe_key({ key_id: i.key_id }).key_metadata.to_h
|
13
|
+
def self._fetch_remote_resources(provider)
|
14
|
+
keys = AwsClients.kms(provider).list_keys[:keys].map do |i|
|
15
|
+
AwsClients.kms(provider).describe_key({ key_id: i.key_id }).key_metadata.to_h
|
15
16
|
end
|
16
17
|
|
17
18
|
keys.map do |k|
|
18
19
|
k[:_terraform_id] = k[:key_id]
|
20
|
+
k[:_arn] = k[:arn]
|
19
21
|
k[:_geo_id] = k[:description]
|
20
22
|
k
|
21
23
|
end
|
@@ -35,17 +35,17 @@ class GeoEngineer::Resources::AwsLambdaAlias < GeoEngineer::Resource
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# TODO(Brad) - May need to implement solution for pagination...
|
38
|
-
def self._fetch_functions
|
38
|
+
def self._fetch_functions(provider)
|
39
39
|
AwsClients
|
40
|
-
.lambda
|
40
|
+
.lambda(provider)
|
41
41
|
.list_functions['functions']
|
42
42
|
.map(&:to_h)
|
43
43
|
end
|
44
44
|
|
45
45
|
# TODO(Brad) - May need to implement solution for pagination...
|
46
|
-
def self._fetch_aliases(function)
|
46
|
+
def self._fetch_aliases(provider, function)
|
47
47
|
options = { function_name: function[:function_name] }
|
48
|
-
AwsClients.lambda.list_aliases(options)[:aliases].map(&:to_h).map do |f_alias|
|
48
|
+
AwsClients.lambda(provider).list_aliases(options)[:aliases].map(&:to_h).map do |f_alias|
|
49
49
|
geo_id_components = [f_alias[:name], function[:function_arn], f_alias[:function_version]]
|
50
50
|
f_alias.merge(
|
51
51
|
{
|
@@ -56,9 +56,9 @@ class GeoEngineer::Resources::AwsLambdaAlias < GeoEngineer::Resource
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def self._fetch_remote_resources
|
60
|
-
_fetch_functions
|
61
|
-
.map { |function| _fetch_aliases(function) }
|
59
|
+
def self._fetch_remote_resources(provider)
|
60
|
+
_fetch_functions(provider)
|
61
|
+
.map { |function| _fetch_aliases(provider, function) }
|
62
62
|
.flatten
|
63
63
|
.compact
|
64
64
|
end
|
@@ -29,9 +29,9 @@ class GeoEngineer::Resources::AwsLambdaEventSourceMapping < GeoEngineer::Resourc
|
|
29
29
|
arn_components[arn_components.index("function") + 1] if arn_components.index("function")
|
30
30
|
end
|
31
31
|
|
32
|
-
def self._fetch_remote_resources
|
32
|
+
def self._fetch_remote_resources(provider)
|
33
33
|
AwsClients
|
34
|
-
.lambda
|
34
|
+
.lambda(provider)
|
35
35
|
.list_event_source_mappings['event_source_mappings']
|
36
36
|
.map(&:to_h)
|
37
37
|
.map do |event|
|
@@ -36,8 +36,8 @@ class GeoEngineer::Resources::AwsLambdaFunction < GeoEngineer::Resource
|
|
36
36
|
false
|
37
37
|
end
|
38
38
|
|
39
|
-
def self._fetch_remote_resources
|
40
|
-
AwsClients.lambda.list_functions['functions'].map(&:to_h).map do |function|
|
39
|
+
def self._fetch_remote_resources(provider)
|
40
|
+
AwsClients.lambda(provider).list_functions['functions'].map(&:to_h).map do |function|
|
41
41
|
function.merge({ _terraform_id: function[:function_name] })
|
42
42
|
end
|
43
43
|
end
|
@@ -21,15 +21,16 @@ class GeoEngineer::Resources::AwsLambdaPermission < GeoEngineer::Resource
|
|
21
21
|
tfstate
|
22
22
|
end
|
23
23
|
|
24
|
-
def self._fetch_functions
|
24
|
+
def self._fetch_functions(provider)
|
25
25
|
AwsClients
|
26
|
-
.lambda
|
26
|
+
.lambda(provider)
|
27
27
|
.list_functions['functions']
|
28
28
|
.map(&:to_h)
|
29
29
|
end
|
30
30
|
|
31
|
-
def self._fetch_policy(function)
|
32
|
-
policy = AwsClients.lambda
|
31
|
+
def self._fetch_policy(provider, function)
|
32
|
+
policy = AwsClients.lambda(provider)
|
33
|
+
.get_policy({ function_name: function[:function_name] })&.policy
|
33
34
|
parsed = _parse_policy(policy) if policy
|
34
35
|
function.merge({ policy: parsed }) if parsed
|
35
36
|
end
|
@@ -60,9 +61,9 @@ class GeoEngineer::Resources::AwsLambdaPermission < GeoEngineer::Resource
|
|
60
61
|
# Right now, this only fetches policies for the $LATEST version
|
61
62
|
# If you want to fetch the policy for a version other than $LATEST
|
62
63
|
# set `find_remote_as_individual?` to `true` for that resource
|
63
|
-
def self._fetch_remote_resources
|
64
|
-
_fetch_functions
|
65
|
-
.map { |function| _fetch_policy(function) }
|
64
|
+
def self._fetch_remote_resources(provider)
|
65
|
+
_fetch_functions(provider)
|
66
|
+
.map { |function| _fetch_policy(provider, function) }
|
66
67
|
.compact
|
67
68
|
.map { |function| _create_permission(function) }
|
68
69
|
.flatten
|
@@ -74,7 +75,7 @@ class GeoEngineer::Resources::AwsLambdaPermission < GeoEngineer::Resource
|
|
74
75
|
params[:qualifier] = qualifier if qualifier
|
75
76
|
|
76
77
|
begin
|
77
|
-
policy = _fetch_policy(params)[:policy]
|
78
|
+
policy = _fetch_policy(fetch_provider, params)[:policy]
|
78
79
|
return {} if policy.nil?
|
79
80
|
rescue Aws::Lambda::Errors::ResourceNotFoundException
|
80
81
|
return {}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
########################################################################
|
2
|
+
# AwsLbCookieStickinessPolicy is the +aws_lb_cookie_stickiness_policy+ terrform resource,
|
3
|
+
#
|
4
|
+
# {https://www.terraform.io/docs/providers/aws/r/lb_cookie_stickiness_policy.html Terraform Docs}
|
5
|
+
########################################################################
|
6
|
+
class GeoEngineer::Resources::AwsLbCookieStickinessPolicy < GeoEngineer::Resource
|
7
|
+
validate -> { validate_required_attributes([:name, :load_balancer, :lb_port]) }
|
8
|
+
|
9
|
+
after :initialize, -> { _terraform_id -> { "#{load_balancer}:#{lb_port}:#{name}" } }
|
10
|
+
|
11
|
+
def support_tags?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def short_type
|
16
|
+
"elbcookiepolicy"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self._generate_policies(elb, policies)
|
20
|
+
policies&.map do |policy|
|
21
|
+
listener = elb[:listener_descriptions]
|
22
|
+
.find { |desc| desc[:policy_names].include?(policy[:policy_name]) }
|
23
|
+
|
24
|
+
next unless listener
|
25
|
+
|
26
|
+
id = "#{elb[:load_balancer_name]}:#{listener[:load_balancer_port]}:#{policy[:policy_name]}"
|
27
|
+
{
|
28
|
+
load_balancer: elb[:load_balancer_name],
|
29
|
+
lb_port: listener[:listener][:load_balancer_port],
|
30
|
+
name: policy[:policy_name],
|
31
|
+
cookie_expiration_period: policy[:cookie_expiration_period],
|
32
|
+
_terraform_id: id
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self._fetch_remote_resources(provider)
|
38
|
+
AwsClients
|
39
|
+
.elb(provider)
|
40
|
+
.describe_load_balancers['load_balancer_descriptions']
|
41
|
+
.map(&:to_h)
|
42
|
+
.select { |elb| !elb.dig(:policies, :lb_cookie_stickiness_policies)&.empty? }
|
43
|
+
.map { |elb| _generate_policies(elb, elb.dig(:policies, :lb_cookie_stickiness_policies)) }
|
44
|
+
.flatten
|
45
|
+
.compact
|
46
|
+
end
|
47
|
+
end
|
@@ -25,9 +25,9 @@ class GeoEngineer::Resources::AwsLoadBalancerBackendServerPolicy < GeoEngineer::
|
|
25
25
|
false
|
26
26
|
end
|
27
27
|
|
28
|
-
def self._fetch_remote_resources
|
28
|
+
def self._fetch_remote_resources(provider)
|
29
29
|
AwsClients
|
30
|
-
.elb
|
30
|
+
.elb(provider)
|
31
31
|
.describe_load_balancers
|
32
32
|
.load_balancer_descriptions
|
33
33
|
.map { |load_balancer| _extract_backend_servers(load_balancer.to_h) }
|
@@ -14,20 +14,20 @@ class GeoEngineer::Resources::AwsLoadBalancerPolicy < GeoEngineer::Resource
|
|
14
14
|
false
|
15
15
|
end
|
16
16
|
|
17
|
-
def self._fetch_remote_resources
|
17
|
+
def self._fetch_remote_resources(provider)
|
18
18
|
AwsClients
|
19
|
-
.elb
|
19
|
+
.elb(provider)
|
20
20
|
.describe_load_balancers
|
21
21
|
.load_balancer_descriptions
|
22
22
|
.map(&:to_h)
|
23
|
-
.map { |load_balancer| _policies_for_load_balancer(load_balancer) }
|
23
|
+
.map { |load_balancer| _policies_for_load_balancer(provider, load_balancer) }
|
24
24
|
.flatten
|
25
25
|
.compact
|
26
26
|
end
|
27
27
|
|
28
|
-
def self._policies_for_load_balancer(load_balancer)
|
28
|
+
def self._policies_for_load_balancer(provider, load_balancer)
|
29
29
|
AwsClients
|
30
|
-
.elb
|
30
|
+
.elb(provider)
|
31
31
|
.describe_load_balancer_policies({ load_balancer_name: load_balancer[:load_balancer_name] })
|
32
32
|
.policy_descriptions
|
33
33
|
.map(&:to_h)
|
@@ -22,9 +22,9 @@ class GeoEngineer::Resources::AwsMainRouteTableAssociation < GeoEngineer::Resour
|
|
22
22
|
false
|
23
23
|
end
|
24
24
|
|
25
|
-
def self._fetch_remote_resources
|
25
|
+
def self._fetch_remote_resources(provider)
|
26
26
|
AwsClients
|
27
|
-
.ec2
|
27
|
+
.ec2(provider)
|
28
28
|
.describe_route_tables['route_tables']
|
29
29
|
.map(&:to_h)
|
30
30
|
.select { |route_table| route_table[:associations] }
|
@@ -13,8 +13,8 @@ class GeoEngineer::Resources::AwsNatGateway < GeoEngineer::Resource
|
|
13
13
|
false
|
14
14
|
end
|
15
15
|
|
16
|
-
def self._fetch_remote_resources
|
17
|
-
AwsClients.ec2.describe_nat_gateways['nat_gateways'].map(&:to_h).map do |gateway|
|
16
|
+
def self._fetch_remote_resources(provider)
|
17
|
+
AwsClients.ec2(provider).describe_nat_gateways['nat_gateways'].map(&:to_h).map do |gateway|
|
18
18
|
# AWS SDK has `nat_gateway_addresses` as an array, but you should only be able to
|
19
19
|
# have exactly 1 elastic IP association. This logic should cover the bases...
|
20
20
|
allocation = gateway[:nat_gateway_addresses].find { |addr| addr.key?(:allocation_id) }
|
@@ -25,8 +25,8 @@ class GeoEngineer::Resources::AwsNetworkAcl < GeoEngineer::Resource
|
|
25
25
|
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
26
26
|
after :initialize, -> { _geo_id -> { NullObject.maybe(tags)[:Name] } }
|
27
27
|
|
28
|
-
def self._fetch_remote_resources
|
29
|
-
AwsClients.ec2.describe_network_acls['network_acls'].map(&:to_h).map do |network_acl|
|
28
|
+
def self._fetch_remote_resources(provider)
|
29
|
+
AwsClients.ec2(provider).describe_network_acls['network_acls'].map(&:to_h).map do |network_acl|
|
30
30
|
network_acl.merge(
|
31
31
|
{
|
32
32
|
_terraform_id: network_acl[:network_acl_id],
|
@@ -36,9 +36,9 @@ class GeoEngineer::Resources::AwsNetworkAclRule < GeoEngineer::Resource
|
|
36
36
|
false
|
37
37
|
end
|
38
38
|
|
39
|
-
def self._fetch_remote_resources
|
39
|
+
def self._fetch_remote_resources(provider)
|
40
40
|
AwsClients
|
41
|
-
.ec2
|
41
|
+
.ec2(provider)
|
42
42
|
.describe_network_acls['network_acls']
|
43
43
|
.map(&:to_h)
|
44
44
|
.select { |network_acl| !network_acl[:entries].empty? }
|