geoengineer 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "./api_gateway/helpers"
|
2
|
+
|
3
|
+
########################################################################
|
4
|
+
# AwsCloudTrail is the +api_gatewat_rest_api+ terrform resource,
|
5
|
+
#
|
6
|
+
# {https://www.terraform.io/docs/providers/aws/r/api_gateway_model.html}
|
7
|
+
########################################################################
|
8
|
+
class GeoEngineer::Resources::AwsApiGatewayModel < GeoEngineer::Resource
|
9
|
+
include GeoEngineer::ApiGatewayHelpers
|
10
|
+
|
11
|
+
validate -> { validate_required_attributes([:rest_api_id, :name, :content_type, :schema]) }
|
12
|
+
|
13
|
+
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
14
|
+
after :initialize, -> { _geo_id -> { rand(36**20).to_s(36) } }
|
15
|
+
|
16
|
+
def support_tags?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative "./api_gateway/helpers"
|
2
|
+
|
3
|
+
########################################################################
|
4
|
+
# AwsCloudTrail is the +api_gatewat_rest_api+ terrform resource,
|
5
|
+
#
|
6
|
+
# {https://www.terraform.io/docs/providers/aws/r/api_gateway_resource.html}
|
7
|
+
########################################################################
|
8
|
+
class GeoEngineer::Resources::AwsApiGatewayResource < GeoEngineer::Resource
|
9
|
+
include GeoEngineer::ApiGatewayHelpers
|
10
|
+
|
11
|
+
# The Rest API resource object and the parent resource object must be passed
|
12
|
+
validate -> { validate_required_attributes([:rest_api_id, :parent_id, :path_part]) }
|
13
|
+
|
14
|
+
after :initialize, -> { self.rest_api_id = _rest_api.to_ref }
|
15
|
+
after :initialize, -> { _rest_api.api_resources[self.type][self.id] = self }
|
16
|
+
|
17
|
+
# Parent is a resource (the default being the root resource of the rest_api '/')
|
18
|
+
# At the moment we only support rest_api being the root resource
|
19
|
+
after :initialize, -> { self.parent_id = _rest_api.to_ref("root_resource_id") }
|
20
|
+
|
21
|
+
after :initialize, -> { depends_on [_rest_api.terraform_name] }
|
22
|
+
|
23
|
+
after :initialize, -> { _geo_id -> { "#{_rest_api._geo_id}::#{path_part}" } }
|
24
|
+
|
25
|
+
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
26
|
+
after :initialize, -> { _id -> { _terraform_id } }
|
27
|
+
|
28
|
+
def to_terraform_state
|
29
|
+
tfstate = super
|
30
|
+
tfstate[:primary][:attributes] = {
|
31
|
+
"rest_api_id" => _rest_api._terraform_id
|
32
|
+
}
|
33
|
+
tfstate
|
34
|
+
end
|
35
|
+
|
36
|
+
def support_tags?
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
def self._fetch_remote_resources(provider)
|
41
|
+
rest_api_resources = []
|
42
|
+
_remote_rest_api_resource(provider) do |rr, res|
|
43
|
+
rest_api_resources << res
|
44
|
+
end
|
45
|
+
rest_api_resources
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative "./api_gateway/helpers"
|
2
|
+
|
3
|
+
########################################################################
|
4
|
+
# AwsCloudTrail is the +api_gatewat_rest_api+ terrform resource,
|
5
|
+
#
|
6
|
+
# {https://www.terraform.io/docs/providers/aws/r/api_gateway_rest_api.html}
|
7
|
+
########################################################################
|
8
|
+
class GeoEngineer::Resources::AwsApiGatewayRestApi < GeoEngineer::Resource
|
9
|
+
include GeoEngineer::ApiGatewayHelpers
|
10
|
+
|
11
|
+
# Validations
|
12
|
+
validate -> { validate_required_attributes([:name]) }
|
13
|
+
|
14
|
+
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
15
|
+
after :initialize, -> { _geo_id -> { name } }
|
16
|
+
|
17
|
+
# API Resource Methods
|
18
|
+
attr_accessor :api_resources
|
19
|
+
after :initialize, :initialize_children_resources
|
20
|
+
|
21
|
+
def initialize_children_resources
|
22
|
+
# { <class_name> : { <resource_id> : <resource>}
|
23
|
+
@api_resources = {
|
24
|
+
"aws_api_gateway_authorizer" => {},
|
25
|
+
"aws_api_gateway_base_path_mapping" => {},
|
26
|
+
"aws_api_gateway_deployment" => {},
|
27
|
+
"aws_api_gateway_integration" => {},
|
28
|
+
"aws_api_gateway_integration_response" => {},
|
29
|
+
"aws_api_gateway_method" => {},
|
30
|
+
"aws_api_gateway_method_response" => {},
|
31
|
+
"aws_api_gateway_model" => {},
|
32
|
+
"aws_api_gateway_resource" => {}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def all_api_resources
|
37
|
+
[self, @api_resources.values.map(&:values)].flatten
|
38
|
+
end
|
39
|
+
|
40
|
+
def all_core_api_resources
|
41
|
+
[
|
42
|
+
self,
|
43
|
+
@api_resources["aws_api_gateway_integration"].values,
|
44
|
+
@api_resources["aws_api_gateway_integration_response"].values,
|
45
|
+
@api_resources["aws_api_gateway_method"].values,
|
46
|
+
@api_resources["aws_api_gateway_method_response"].values,
|
47
|
+
@api_resources["aws_api_gateway_model"].values,
|
48
|
+
@api_resources["aws_api_gateway_resource"].values
|
49
|
+
].flatten
|
50
|
+
end
|
51
|
+
|
52
|
+
# End of API Resource Methods
|
53
|
+
def support_tags?
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def root_resource_id
|
58
|
+
NullObject.maybe(remote_resource).root_resource_id
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_terraform_state
|
62
|
+
tfstate = super
|
63
|
+
tfstate[:primary][:attributes] = {
|
64
|
+
"root_resource_id" => root_resource_id
|
65
|
+
}
|
66
|
+
tfstate
|
67
|
+
end
|
68
|
+
|
69
|
+
# This method will tag for deletion all remote resources that are not codeified
|
70
|
+
def delete_uncodified_children_resoures
|
71
|
+
# Find all remote resources for this rest_api
|
72
|
+
# Compare with api_resources hash
|
73
|
+
# create resource in project tagged with deletion (this will only add them to tfstate)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self._fetch_remote_resources(provider)
|
77
|
+
_fetch_remote_rest_apis(provider)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "./api_gateway/helpers"
|
2
|
+
|
3
|
+
########################################################################
|
4
|
+
# AwsCloudTrail is the +api_gatewat_rest_api+ terrform resource,
|
5
|
+
#
|
6
|
+
# {https://www.terraform.io/docs/providers/aws/r/api_gateway_usage_plan.html}
|
7
|
+
########################################################################
|
8
|
+
class GeoEngineer::Resources::AwsApiGatewayUsagePlan < GeoEngineer::Resource
|
9
|
+
include GeoEngineer::ApiGatewayHelpers
|
10
|
+
|
11
|
+
validate -> { validate_required_attributes([:name, :description]) }
|
12
|
+
|
13
|
+
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
14
|
+
after :initialize, -> { _geo_id -> { name } }
|
15
|
+
|
16
|
+
def support_tags?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def self._fetch_remote_resources(provider)
|
21
|
+
AwsClients.api_gateway(provider).get_usage_plans['items'].map(&:to_h).map do |api|
|
22
|
+
api[:_terraform_id] = api[:id]
|
23
|
+
api[:_geo_id] = api[:name]
|
24
|
+
api
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
########################################################################
|
2
|
+
# AwsCloudfrontDistribution is the +aws_cloudfront_distribution+
|
3
|
+
# terraform resource,
|
4
|
+
#
|
5
|
+
# {https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html}
|
6
|
+
########################################################################
|
7
|
+
class GeoEngineer::Resources::AwsCloudfrontDistribution < GeoEngineer::Resource
|
8
|
+
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
9
|
+
after :initialize, -> { _geo_id -> { comment } }
|
10
|
+
after :initialize, -> { _arn -> { NullObject.maybe(remote_resource)._arn } }
|
11
|
+
|
12
|
+
def self._fetch_remote_resources(provider)
|
13
|
+
AwsClients.cloudfront(provider).list_distributions[:distribution_list][:items].map do |item|
|
14
|
+
item.to_h.tap do |i|
|
15
|
+
i[:_terraform_id] = item.id
|
16
|
+
i[:_arn] = item.arn
|
17
|
+
i[:_geo_id] = item[:comment]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def support_tags?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
@@ -8,8 +8,8 @@ class GeoEngineer::Resources::AwsCloudtrail < GeoEngineer::Resource
|
|
8
8
|
|
9
9
|
after :initialize, -> { _terraform_id -> { name } }
|
10
10
|
|
11
|
-
def self._fetch_remote_resources
|
12
|
-
cloudtrails = AwsClients.cloudtrail.describe_trails["trail_list"].map(&:to_h)
|
11
|
+
def self._fetch_remote_resources(provider)
|
12
|
+
cloudtrails = AwsClients.cloudtrail(provider).describe_trails["trail_list"].map(&:to_h)
|
13
13
|
|
14
14
|
cloudtrails.map do |ct|
|
15
15
|
ct[:_terraform_id] = ct[:name]
|
@@ -4,7 +4,14 @@
|
|
4
4
|
# {https://www.terraform.io/docs/providers/aws/r/cloudwatch_event_rule.html Terraform Docs}
|
5
5
|
########################################################################
|
6
6
|
class GeoEngineer::Resources::AwsCloudwatchEventRule < GeoEngineer::Resource
|
7
|
-
validate -> { validate_required_attributes([:name
|
7
|
+
validate -> { validate_required_attributes([:name]) }
|
8
|
+
validate -> { validate_schedule_or_event }
|
9
|
+
|
10
|
+
def validate_schedule_or_event
|
11
|
+
return if !self[:schedule_expression] && self[:event_pattern]
|
12
|
+
return if self[:schedule_expression] && !self[:event_pattern]
|
13
|
+
["#{self.id}: Need either schedule_expression or event_pattern defined"]
|
14
|
+
end
|
8
15
|
|
9
16
|
after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
|
10
17
|
after :initialize, -> { _geo_id -> { self[:name] } }
|
@@ -13,8 +20,10 @@ class GeoEngineer::Resources::AwsCloudwatchEventRule < GeoEngineer::Resource
|
|
13
20
|
false
|
14
21
|
end
|
15
22
|
|
16
|
-
def self._fetch_remote_resources
|
17
|
-
AwsClients
|
23
|
+
def self._fetch_remote_resources(provider)
|
24
|
+
AwsClients
|
25
|
+
.cloudwatchevents(provider)
|
26
|
+
.list_rules.rules.map(&:to_h).map do |cloudwatch_event_rule|
|
18
27
|
cloudwatch_event_rule.merge(
|
19
28
|
{
|
20
29
|
_terraform_id: cloudwatch_event_rule[:name],
|
@@ -22,9 +22,9 @@ class GeoEngineer::Resources::AwsCloudwatchEventTarget < GeoEngineer::Resource
|
|
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
|
-
.cloudwatchevents
|
27
|
+
.cloudwatchevents(provider)
|
28
28
|
.list_rules
|
29
29
|
.rules
|
30
30
|
.map(&:to_h)
|
@@ -23,8 +23,8 @@ class GeoEngineer::Resources::AwsCloudwatchMetricAlarm < GeoEngineer::Resource
|
|
23
23
|
false
|
24
24
|
end
|
25
25
|
|
26
|
-
def self._fetch_remote_resources
|
27
|
-
_get_all_alarms.map { |alarm|
|
26
|
+
def self._fetch_remote_resources(provider)
|
27
|
+
_get_all_alarms(provider).map { |alarm|
|
28
28
|
{
|
29
29
|
_terraform_id: alarm[:alarm_name],
|
30
30
|
_geo_id: alarm[:alarm_name],
|
@@ -33,14 +33,16 @@ class GeoEngineer::Resources::AwsCloudwatchMetricAlarm < GeoEngineer::Resource
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
-
def self._get_all_alarms
|
37
|
-
alarm_page = AwsClients.cloudwatch.describe_alarms({ max_records: 100 })
|
36
|
+
def self._get_all_alarms(provider)
|
37
|
+
alarm_page = AwsClients.cloudwatch(provider).describe_alarms({ max_records: 100 })
|
38
38
|
alarms = alarm_page.metric_alarms.map(&:to_h)
|
39
39
|
while alarm_page.next_token
|
40
|
-
alarm_page = AwsClients
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
alarm_page = AwsClients
|
41
|
+
.cloudwatch(provider)
|
42
|
+
.describe_alarms({
|
43
|
+
max_records: 100,
|
44
|
+
next_token: alarm_page.next_token
|
45
|
+
})
|
44
46
|
alarms.concat alarm_page.metric_alarms.map(&:to_h)
|
45
47
|
end
|
46
48
|
alarms
|
@@ -10,8 +10,10 @@ class GeoEngineer::Resources::AwsCustomerGateway < 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_customer_gateways['customer_gateways']
|
16
|
+
.map(&:to_h).map do |gateway|
|
15
17
|
gateway.merge(
|
16
18
|
{
|
17
19
|
_terraform_id: gateway[:customer_gateway_id],
|
@@ -39,8 +39,8 @@ class GeoEngineer::Resources::AwsDbInstance < GeoEngineer::Resource
|
|
39
39
|
"db"
|
40
40
|
end
|
41
41
|
|
42
|
-
def self._fetch_remote_resources
|
43
|
-
AwsClients.rds.describe_db_instances['db_instances'].map(&:to_h).map do |rds|
|
42
|
+
def self._fetch_remote_resources(provider)
|
43
|
+
AwsClients.rds(provider).describe_db_instances['db_instances'].map(&:to_h).map do |rds|
|
44
44
|
rds[:_terraform_id] = rds[:db_instance_identifier]
|
45
45
|
rds[:_geo_id] = rds[:db_instance_identifier]
|
46
46
|
rds[:identifier] = rds[:db_instance_identifier]
|
@@ -14,8 +14,10 @@ class GeoEngineer::Resources::AwsDbParameterGroup < GeoEngineer::Resource
|
|
14
14
|
"dbpg"
|
15
15
|
end
|
16
16
|
|
17
|
-
def self._fetch_remote_resources
|
18
|
-
AwsClients.rds
|
17
|
+
def self._fetch_remote_resources(provider)
|
18
|
+
AwsClients.rds(provider)
|
19
|
+
.describe_db_parameter_groups['db_parameter_groups']
|
20
|
+
.map(&:to_h).map do |pg|
|
19
21
|
pg[:_terraform_id] = pg[:db_parameter_group_name]
|
20
22
|
pg[:_geo_id] = pg[:db_parameter_group_name]
|
21
23
|
pg[:name] = pg[:db_parameter_group_name]
|
@@ -12,8 +12,8 @@ class GeoEngineer::Resources::AwsDynamodbTable < GeoEngineer::Resource
|
|
12
12
|
false
|
13
13
|
end
|
14
14
|
|
15
|
-
def self._fetch_remote_resources
|
16
|
-
AwsClients.dynamo.list_tables['table_names'].map { |name|
|
15
|
+
def self._fetch_remote_resources(provider)
|
16
|
+
AwsClients.dynamo(provider).list_tables['table_names'].map { |name|
|
17
17
|
{
|
18
18
|
name: name,
|
19
19
|
_geo_id: name,
|
@@ -33,8 +33,8 @@ class GeoEngineer::Resources::AwsEip < GeoEngineer::Resource
|
|
33
33
|
true
|
34
34
|
end
|
35
35
|
|
36
|
-
def self._fetch_remote_resources
|
37
|
-
AwsClients.ec2.describe_addresses['addresses'].map(&:to_h).map do |address|
|
36
|
+
def self._fetch_remote_resources(provider)
|
37
|
+
AwsClients.ec2(provider).describe_addresses['addresses'].map(&:to_h).map do |address|
|
38
38
|
address[:_terraform_id] = address[:allocation_id]
|
39
39
|
address[:_geo_id] = address[:public_ip]
|
40
40
|
address
|
@@ -45,9 +45,9 @@ class GeoEngineer::Resources::AwsElasticacheCluster < GeoEngineer::Resource
|
|
45
45
|
"ec"
|
46
46
|
end
|
47
47
|
|
48
|
-
def self._fetch_remote_resources
|
48
|
+
def self._fetch_remote_resources(provider)
|
49
49
|
AwsClients
|
50
|
-
.elasticache
|
50
|
+
.elasticache(provider)
|
51
51
|
.describe_cache_clusters['cache_clusters']
|
52
52
|
.map(&:to_h)
|
53
53
|
.select { |ec| ec[:replication_group_id].nil? }
|
@@ -18,8 +18,8 @@ class GeoEngineer::Resources::AwsElasticacheParameterGroup < GeoEngineer::Resour
|
|
18
18
|
"ecpg"
|
19
19
|
end
|
20
20
|
|
21
|
-
def self._fetch_remote_resources
|
22
|
-
ec = AwsClients.elasticache
|
21
|
+
def self._fetch_remote_resources(provider)
|
22
|
+
ec = AwsClients.elasticache(provider)
|
23
23
|
ec.describe_cache_parameter_groups['cache_parameter_groups'].map(&:to_h).map do |pg|
|
24
24
|
pg[:_terraform_id] = pg[:cache_parameter_group_name]
|
25
25
|
pg[:_geo_id] = pg[:cache_parameter_group_name]
|
@@ -33,8 +33,8 @@ class GeoEngineer::Resources::AwsElasticacheReplicationGroup < GeoEngineer::Reso
|
|
33
33
|
tfstate
|
34
34
|
end
|
35
35
|
|
36
|
-
def self._fetch_remote_resources
|
37
|
-
ec = AwsClients.elasticache
|
36
|
+
def self._fetch_remote_resources(provider)
|
37
|
+
ec = AwsClients.elasticache(provider)
|
38
38
|
ec.describe_replication_groups['replication_groups'].map(&:to_h).map do |rg|
|
39
39
|
rg[:_terraform_id] = rg[:replication_group_id]
|
40
40
|
rg[:_geo_id] = rg[:replication_group_id]
|
@@ -12,8 +12,8 @@ class GeoEngineer::Resources::AwsElasticacheSubnetGroup < GeoEngineer::Resource
|
|
12
12
|
false
|
13
13
|
end
|
14
14
|
|
15
|
-
def self._fetch_remote_resources
|
16
|
-
cache_subnet_groups = AwsClients.elasticache.describe_cache_subnet_groups
|
15
|
+
def self._fetch_remote_resources(provider)
|
16
|
+
cache_subnet_groups = AwsClients.elasticache(provider).describe_cache_subnet_groups
|
17
17
|
|
18
18
|
cache_subnet_groups['cache_subnet_groups'].map(&:to_h).map do |csg|
|
19
19
|
csg[:name] = csg[:cache_subnet_group_name]
|
@@ -26,8 +26,8 @@ class GeoEngineer::Resources::AwsElasticsearchDomain < GeoEngineer::Resource
|
|
26
26
|
"es"
|
27
27
|
end
|
28
28
|
|
29
|
-
def self._fetch_remote_resources
|
30
|
-
AwsClients.elasticsearch.list_domain_names['domain_names'].map(&:to_h).map do |esd|
|
29
|
+
def self._fetch_remote_resources(provider)
|
30
|
+
AwsClients.elasticsearch(provider).list_domain_names['domain_names'].map(&:to_h).map do |esd|
|
31
31
|
esd[:_geo_id] = esd[:domain_name]
|
32
32
|
esd
|
33
33
|
end
|
@@ -46,8 +46,10 @@ class GeoEngineer::Resources::AwsElb < GeoEngineer::Resource
|
|
46
46
|
"elb"
|
47
47
|
end
|
48
48
|
|
49
|
-
def self._fetch_remote_resources
|
50
|
-
AwsClients.elb
|
49
|
+
def self._fetch_remote_resources(provider)
|
50
|
+
AwsClients.elb(provider)
|
51
|
+
.describe_load_balancers['load_balancer_descriptions']
|
52
|
+
.map(&:to_h).map do |elb|
|
51
53
|
elb[:_terraform_id] = elb[:load_balancer_name]
|
52
54
|
elb[:_geo_id] = elb[:load_balancer_name]
|
53
55
|
elb[:name] = elb[:load_balancer_name]
|
@@ -24,7 +24,8 @@ class GeoEngineer::Resources::AwsIamAccountPasswordPolicy < GeoEngineer::Resourc
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def remote_resource_params
|
27
|
-
password_policy = AwsClients.iam
|
27
|
+
password_policy = AwsClients.iam(fetch_provider)
|
28
|
+
.get_account_password_policy.password_policy.to_h
|
28
29
|
password_policy.merge({ _geo_id: SINGLETON_ID, _terraform_id: SINGLETON_ID })
|
29
30
|
rescue Aws::IAM::Errors::NoSuchEntity
|
30
31
|
{}
|
@@ -13,8 +13,8 @@ class GeoEngineer::Resources::AwsIamGroup < GeoEngineer::Resource
|
|
13
13
|
false
|
14
14
|
end
|
15
15
|
|
16
|
-
def self._fetch_remote_resources
|
17
|
-
groups = AwsClients.iam.list_groups['groups'].map(&:to_h)
|
16
|
+
def self._fetch_remote_resources(provider)
|
17
|
+
groups = AwsClients.iam(provider).list_groups['groups'].map(&:to_h)
|
18
18
|
|
19
19
|
groups.map do |g|
|
20
20
|
g[:name] = g[:group_name]
|