geoengineer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +8 -6
  5. data/lib/geoengineer.rb +2 -0
  6. data/lib/geoengineer/cli/geo_cli.rb +1 -4
  7. data/lib/geoengineer/cli/terraform_commands.rb +4 -2
  8. data/lib/geoengineer/environment.rb +14 -1
  9. data/lib/geoengineer/provider.rb +38 -0
  10. data/lib/geoengineer/resource.rb +29 -15
  11. data/lib/geoengineer/resources/api_gateway/helpers.rb +107 -0
  12. data/lib/geoengineer/resources/aws_alb.rb +39 -0
  13. data/lib/geoengineer/resources/aws_alb_listener.rb +39 -0
  14. data/lib/geoengineer/resources/aws_alb_listener_rule.rb +42 -0
  15. data/lib/geoengineer/resources/aws_alb_target_group.rb +30 -0
  16. data/lib/geoengineer/resources/aws_api_gateway_account.rb +18 -0
  17. data/lib/geoengineer/resources/aws_api_gateway_api_key.rb +20 -0
  18. data/lib/geoengineer/resources/aws_api_gateway_authorizer.rb +20 -0
  19. data/lib/geoengineer/resources/aws_api_gateway_base_path_mapping.rb +20 -0
  20. data/lib/geoengineer/resources/aws_api_gateway_client_certificate.rb +24 -0
  21. data/lib/geoengineer/resources/aws_api_gateway_deployment.rb +65 -0
  22. data/lib/geoengineer/resources/aws_api_gateway_domain_name.rb +27 -0
  23. data/lib/geoengineer/resources/aws_api_gateway_integration.rb +58 -0
  24. data/lib/geoengineer/resources/aws_api_gateway_integration_response.rb +68 -0
  25. data/lib/geoengineer/resources/aws_api_gateway_method.rb +59 -0
  26. data/lib/geoengineer/resources/aws_api_gateway_method_response.rb +69 -0
  27. data/lib/geoengineer/resources/aws_api_gateway_model.rb +19 -0
  28. data/lib/geoengineer/resources/aws_api_gateway_resource.rb +47 -0
  29. data/lib/geoengineer/resources/aws_api_gateway_rest_api.rb +79 -0
  30. data/lib/geoengineer/resources/aws_api_gateway_usage_plan.rb +27 -0
  31. data/lib/geoengineer/resources/aws_cloudfront_distribution.rb +25 -0
  32. data/lib/geoengineer/resources/aws_cloudtrail.rb +2 -2
  33. data/lib/geoengineer/resources/aws_cloudwatch_event_rule.rb +12 -3
  34. data/lib/geoengineer/resources/aws_cloudwatch_event_target.rb +2 -2
  35. data/lib/geoengineer/resources/aws_cloudwatch_metric_alarm.rb +10 -8
  36. data/lib/geoengineer/resources/aws_customer_gateway.rb +4 -2
  37. data/lib/geoengineer/resources/aws_db_instance.rb +2 -2
  38. data/lib/geoengineer/resources/aws_db_parameter_group.rb +4 -2
  39. data/lib/geoengineer/resources/aws_dynamodb_table.rb +2 -2
  40. data/lib/geoengineer/resources/aws_eip.rb +2 -2
  41. data/lib/geoengineer/resources/aws_elasticache_cluster.rb +2 -2
  42. data/lib/geoengineer/resources/aws_elasticache_parameter_group.rb +2 -2
  43. data/lib/geoengineer/resources/aws_elasticache_replication_group.rb +2 -2
  44. data/lib/geoengineer/resources/aws_elasticache_subnet_group.rb +2 -2
  45. data/lib/geoengineer/resources/aws_elasticsearch_domain.rb +2 -2
  46. data/lib/geoengineer/resources/aws_elb.rb +4 -2
  47. data/lib/geoengineer/resources/aws_iam_account_password_policy.rb +2 -1
  48. data/lib/geoengineer/resources/aws_iam_group.rb +2 -2
  49. data/lib/geoengineer/resources/aws_iam_group_membership.rb +1 -1
  50. data/lib/geoengineer/resources/aws_iam_instance_profile.rb +3 -3
  51. data/lib/geoengineer/resources/aws_iam_policy.rb +6 -4
  52. data/lib/geoengineer/resources/aws_iam_policy_attachment.rb +1 -1
  53. data/lib/geoengineer/resources/aws_iam_role.rb +2 -2
  54. data/lib/geoengineer/resources/aws_iam_role_policy.rb +10 -9
  55. data/lib/geoengineer/resources/aws_iam_user.rb +4 -4
  56. data/lib/geoengineer/resources/aws_instance.rb +3 -3
  57. data/lib/geoengineer/resources/aws_internet_gateway.rb +3 -2
  58. data/lib/geoengineer/resources/aws_kinesis_stream.rb +4 -4
  59. data/lib/geoengineer/resources/aws_kms_key.rb +5 -3
  60. data/lib/geoengineer/resources/aws_lambda_alias.rb +7 -7
  61. data/lib/geoengineer/resources/aws_lambda_event_source_mapping.rb +2 -2
  62. data/lib/geoengineer/resources/aws_lambda_function.rb +2 -2
  63. data/lib/geoengineer/resources/aws_lambda_permission.rb +9 -8
  64. data/lib/geoengineer/resources/aws_lb_cookie_stickiness_policy.rb +47 -0
  65. data/lib/geoengineer/resources/aws_load_balancer_backend_server_policy.rb +2 -2
  66. data/lib/geoengineer/resources/aws_load_balancer_policy.rb +5 -5
  67. data/lib/geoengineer/resources/aws_main_route_table_association.rb +2 -2
  68. data/lib/geoengineer/resources/aws_nat_gateway.rb +2 -2
  69. data/lib/geoengineer/resources/aws_network_acl.rb +2 -2
  70. data/lib/geoengineer/resources/aws_network_acl_rule.rb +2 -2
  71. data/lib/geoengineer/resources/aws_proxy_protocol_policy.rb +1 -1
  72. data/lib/geoengineer/resources/aws_redshift_cluster.rb +2 -2
  73. data/lib/geoengineer/resources/aws_route.rb +2 -2
  74. data/lib/geoengineer/resources/aws_route53_record.rb +6 -6
  75. data/lib/geoengineer/resources/aws_route53_zone.rb +2 -2
  76. data/lib/geoengineer/resources/aws_route_table.rb +2 -2
  77. data/lib/geoengineer/resources/aws_route_table_association.rb +2 -2
  78. data/lib/geoengineer/resources/aws_s3_bucket.rb +2 -2
  79. data/lib/geoengineer/resources/aws_s3_bucket_notification.rb +38 -0
  80. data/lib/geoengineer/resources/aws_security_group.rb +2 -2
  81. data/lib/geoengineer/resources/aws_ses_receipt_rule.rb +2 -2
  82. data/lib/geoengineer/resources/aws_ses_receipt_rule_set.rb +2 -2
  83. data/lib/geoengineer/resources/aws_sns_topic.rb +2 -2
  84. data/lib/geoengineer/resources/aws_sns_topic_subscription.rb +5 -5
  85. data/lib/geoengineer/resources/aws_sqs_queue.rb +2 -2
  86. data/lib/geoengineer/resources/aws_subnet.rb +2 -2
  87. data/lib/geoengineer/resources/aws_vpc.rb +2 -2
  88. data/lib/geoengineer/resources/aws_vpc_dhcp_options.rb +2 -2
  89. data/lib/geoengineer/resources/aws_vpc_dhcp_options_association.rb +2 -2
  90. data/lib/geoengineer/resources/aws_vpc_endpoint.rb +2 -2
  91. data/lib/geoengineer/resources/aws_vpc_peering_connection.rb +2 -2
  92. data/lib/geoengineer/resources/aws_vpn_connection.rb +3 -2
  93. data/lib/geoengineer/resources/aws_vpn_connection_route.rb +2 -2
  94. data/lib/geoengineer/resources/aws_vpn_gateway.rb +2 -2
  95. data/lib/geoengineer/resources/aws_vpn_gateway_attachment.rb +2 -2
  96. data/lib/geoengineer/template.rb +3 -1
  97. data/lib/geoengineer/templates/json_rest_api.rb +197 -0
  98. data/lib/geoengineer/utils/aws_clients.rb +129 -38
  99. data/lib/geoengineer/utils/has_templates.rb +1 -1
  100. data/lib/geoengineer/version.rb +1 -1
  101. data/spec/environment_spec.rb +1 -1
  102. data/spec/resource_spec.rb +24 -10
  103. data/spec/resources/aws_alb_listener_rule_spec.rb +45 -0
  104. data/spec/resources/aws_alb_listener_spec.rb +33 -0
  105. data/spec/resources/aws_alb_spec.rb +33 -0
  106. data/spec/resources/aws_alb_target_group_spec.rb +35 -0
  107. data/spec/resources/aws_api_gateway_account_spec.rb +6 -0
  108. data/spec/resources/aws_api_gateway_api_key_spec.rb +6 -0
  109. data/spec/resources/aws_api_gateway_authorizer_spec.rb +6 -0
  110. data/spec/resources/aws_api_gateway_base_path_mapping_spec.rb +6 -0
  111. data/spec/resources/aws_api_gateway_client_certificate_spec.rb +6 -0
  112. data/spec/resources/aws_api_gateway_deployment_spec.rb +6 -0
  113. data/spec/resources/aws_api_gateway_domain_name_spec.rb +6 -0
  114. data/spec/resources/aws_api_gateway_integration_response_spec.rb +6 -0
  115. data/spec/resources/aws_api_gateway_integration_spec.rb +6 -0
  116. data/spec/resources/aws_api_gateway_method_response_spec.rb +6 -0
  117. data/spec/resources/aws_api_gateway_method_spec.rb +6 -0
  118. data/spec/resources/aws_api_gateway_model_spec.rb +6 -0
  119. data/spec/resources/aws_api_gateway_resource_spec.rb +6 -0
  120. data/spec/resources/aws_api_gateway_rest_api_spec.rb +6 -0
  121. data/spec/resources/aws_cloudfront_distribution_spec.rb +50 -0
  122. data/spec/resources/aws_cloudtrail_spec.rb +3 -3
  123. data/spec/resources/aws_cloudwatch_event_rule_spec.rb +3 -3
  124. data/spec/resources/aws_cloudwatch_event_target_spec.rb +4 -6
  125. data/spec/resources/aws_cloudwatch_metric_alarm_spec.rb +3 -6
  126. data/spec/resources/aws_customer_gateway_spec.rb +4 -3
  127. data/spec/resources/aws_db_instance_spec.rb +3 -3
  128. data/spec/resources/aws_db_parameter_group_spec.rb +3 -3
  129. data/spec/resources/aws_dynamodb_table_spec.rb +3 -3
  130. data/spec/resources/aws_eip_spec.rb +3 -3
  131. data/spec/resources/aws_elasticache_replication_group_spec.rb +3 -6
  132. data/spec/resources/aws_elasticache_subnet_group_spec.rb +4 -6
  133. data/spec/resources/aws_elasticcache_cluster_spec.rb +3 -3
  134. data/spec/resources/aws_elasticcache_parameter_group_spec.rb +3 -6
  135. data/spec/resources/aws_elasticsearch_domain_spec.rb +3 -3
  136. data/spec/resources/aws_elb_spec.rb +3 -3
  137. data/spec/resources/aws_iam_account_password_policy_spec.rb +2 -6
  138. data/spec/resources/aws_iam_group_membership_spec.rb +2 -6
  139. data/spec/resources/aws_iam_group_spec.rb +3 -3
  140. data/spec/resources/aws_iam_instance_profile_spec.rb +3 -6
  141. data/spec/resources/aws_iam_policy_attachment_spec.rb +2 -6
  142. data/spec/resources/aws_iam_policy_spec.rb +3 -5
  143. data/spec/resources/aws_iam_role_spec.rb +3 -4
  144. data/spec/resources/aws_iam_rule_policy_spec.rb +2 -5
  145. data/spec/resources/aws_iam_user_spec.rb +3 -4
  146. data/spec/resources/aws_instance_spec.rb +3 -3
  147. data/spec/resources/aws_internet_gateway_spec.rb +3 -3
  148. data/spec/resources/aws_kinesis_stream_spec.rb +3 -4
  149. data/spec/resources/aws_kms_key_spec.rb +3 -3
  150. data/spec/resources/aws_lambda_alias_spec.rb +2 -3
  151. data/spec/resources/aws_lambda_event_source_mapping_spec.rb +2 -5
  152. data/spec/resources/aws_lambda_function_spec.rb +3 -4
  153. data/spec/resources/aws_lambda_permission_spec.rb +1 -1
  154. data/spec/resources/aws_lb_cookie_stickiness_policy_spec.rb +38 -0
  155. data/spec/resources/aws_load_balancer_backend_server_policy_spec.rb +2 -3
  156. data/spec/resources/aws_load_balancer_policy_spec.rb +3 -4
  157. data/spec/resources/aws_main_route_table_association_spec.rb +2 -5
  158. data/spec/resources/aws_nat_gateway_spec.rb +3 -4
  159. data/spec/resources/aws_network_acl_rule_spec.rb +2 -3
  160. data/spec/resources/aws_network_acl_spec.rb +3 -3
  161. data/spec/resources/aws_proxy_protocol_policy_spec.rb +2 -2
  162. data/spec/resources/aws_redshift_cluster_spec.rb +3 -3
  163. data/spec/resources/aws_route53_record_spec.rb +3 -4
  164. data/spec/resources/aws_route53_zone_spec.rb +3 -4
  165. data/spec/resources/aws_route_spec.rb +3 -6
  166. data/spec/resources/aws_route_table_association_spec.rb +4 -6
  167. data/spec/resources/aws_route_table_spec.rb +3 -3
  168. data/spec/resources/aws_s3_bucket_notification_spec.rb +4 -0
  169. data/spec/resources/aws_s3_bucket_spec.rb +3 -3
  170. data/spec/resources/aws_security_group_spec.rb +5 -5
  171. data/spec/resources/aws_ses_receipt_rule_set_spec.rb +3 -4
  172. data/spec/resources/aws_ses_receipt_rule_spec.rb +3 -4
  173. data/spec/resources/aws_sns_topic_spec.rb +10 -6
  174. data/spec/resources/aws_sns_topic_subscription_spec.rb +8 -7
  175. data/spec/resources/aws_sqs_queue_spec.rb +3 -3
  176. data/spec/resources/aws_subnet_spec.rb +3 -3
  177. data/spec/resources/aws_vpc_dhcp_options_association_spec.rb +3 -6
  178. data/spec/resources/aws_vpc_dhcp_options_spec.rb +3 -3
  179. data/spec/resources/aws_vpc_endpoint_spec.rb +3 -6
  180. data/spec/resources/aws_vpc_peering_connection_spec.rb +4 -6
  181. data/spec/resources/aws_vpc_spec.rb +3 -3
  182. data/spec/resources/aws_vpn_connection_route_spec.rb +3 -6
  183. data/spec/resources/aws_vpn_connection_spec.rb +3 -3
  184. data/spec/resources/aws_vpn_gateway_attachment_spec.rb +4 -6
  185. data/spec/resources/aws_vpn_gateway_spec.rb +3 -3
  186. data/spec/spec_helper.rb +3 -1
  187. data/spec/support/normalize_indent.rb +12 -0
  188. metadata +92 -22
  189. metadata.gz.sig +0 -0
@@ -0,0 +1,30 @@
1
+ ########################################################################
2
+ # AwsAlbTargetGroup is the +aws_alb_target_group+ terrform resource,
3
+ #
4
+ # {https://www.terraform.io/docs/providers/aws/r/alb_target_group.html Terraform Docs}
5
+ ########################################################################
6
+ class GeoEngineer::Resources::AwsAlbTargetGroup < GeoEngineer::Resource
7
+ validate -> {
8
+ validate_required_attributes([:port, :protocol, :vpc_id])
9
+ }
10
+ validate -> { validate_subresource_required_attributes(:stickiness, [:type]) }
11
+
12
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
13
+ after :initialize, -> { _geo_id -> { "#{vpc_id}::#{protocol}::#{port}" } }
14
+
15
+ def short_type
16
+ "alb_target_group"
17
+ end
18
+
19
+ def self._fetch_remote_resources(provider)
20
+ target_groups = AwsClients.alb(provider).describe_target_groups.target_groups.map(&:to_h)
21
+ target_groups.map do |group|
22
+ group.merge(
23
+ {
24
+ _geo_id: "#{group[:vpc_id]}::#{group[:protocol]}::#{group[:port]}",
25
+ _terraform_id: group[:target_group_arn]
26
+ }
27
+ )
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
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_account.html}
7
+ ########################################################################
8
+ # TODO: not fully implemented
9
+ class GeoEngineer::Resources::AwsApiGatewayAccount < GeoEngineer::Resource
10
+ include GeoEngineer::ApiGatewayHelpers
11
+
12
+ after :initialize, -> { _terraform_id -> { nil } }
13
+ after :initialize, -> { _geo_id -> { rand(36**20).to_s(36) } }
14
+
15
+ def support_tags?
16
+ false
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +aws_api_gateway_api_key+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/aws_api_gateway_api_key.html}
7
+ ########################################################################
8
+ # TODO: not fully implemented
9
+ class GeoEngineer::Resources::AwsApiGatewayApiKey < GeoEngineer::Resource
10
+ include GeoEngineer::ApiGatewayHelpers
11
+
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
+ def support_tags?
18
+ false
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +aws_api_gateway_authorizer+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/aws_api_gateway_authorizer.html}
7
+ ########################################################################
8
+ # TODO: not fully implemented
9
+ class GeoEngineer::Resources::AwsApiGatewayAuthorizer < GeoEngineer::Resource
10
+ include GeoEngineer::ApiGatewayHelpers
11
+
12
+ validate -> { validate_required_attributes([:authorizer_uri, :name, :rest_api_id]) }
13
+
14
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
15
+ after :initialize, -> { _geo_id -> { name } }
16
+
17
+ def support_tags?
18
+ false
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +aws_api_gateway_base_path_mapping+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/aws_api_gateway_base_path_mapping.html}
7
+ ########################################################################
8
+ # TODO: not fully implemented
9
+ class GeoEngineer::Resources::AwsApiGatewayBasePathMapping < GeoEngineer::Resource
10
+ include GeoEngineer::ApiGatewayHelpers
11
+
12
+ validate -> { validate_required_attributes([:domain_name, :rest_api_id]) }
13
+
14
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
15
+ after :initialize, -> { _geo_id -> { domain_name } }
16
+
17
+ def support_tags?
18
+ false
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +aws_api_gateway_client_certificate+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/aws_api_gateway_client_certificate.html}
7
+ ########################################################################
8
+ # TODO: not fully implemented
9
+ class GeoEngineer::Resources::AwsApiGatewayClientCertificate < GeoEngineer::Resource
10
+ include GeoEngineer::ApiGatewayHelpers
11
+
12
+ validate -> {
13
+ validate_required_attributes([
14
+ :description
15
+ ])
16
+ }
17
+
18
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
19
+ after :initialize, -> { _geo_id -> { description } }
20
+
21
+ def support_tags?
22
+ false
23
+ end
24
+ end
@@ -0,0 +1,65 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +api_gateway_deployment+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/api_gateway_deployment.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayDeployment < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([:rest_api_id, :stage_name])
13
+ }
14
+
15
+ after :initialize, -> {
16
+ if self._rest_api
17
+ self.rest_api_id = _rest_api.to_ref
18
+ _rest_api.api_resources[self.type][self.id] = self
19
+ depends_on [_rest_api].map(&:terraform_name)
20
+ end
21
+ }
22
+
23
+ after :initialize, -> { _geo_id -> { "#{_rest_api._geo_id}::#{stage_name}" } }
24
+
25
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
26
+
27
+ def to_terraform_state
28
+ tfstate = super
29
+ tfstate[:primary][:attributes] = {
30
+ "rest_api_id" => _rest_api._terraform_id,
31
+ "stage_name" => stage_name
32
+ }
33
+ tfstate
34
+ end
35
+
36
+ def support_tags?
37
+ false
38
+ end
39
+
40
+ def self._fetch_deployments(provider, rr)
41
+ _client(provider).get_deployments({
42
+ rest_api_id: rr[:_terraform_id]
43
+ })['items'].map(&:to_h)
44
+ end
45
+
46
+ def self._fetch_stage_name(provider, rr, deployment)
47
+ _client(provider).get_stages({
48
+ rest_api_id: rr[:_terraform_id],
49
+ deployment_id: deployment[:id]
50
+ }).item.first&.stage_name
51
+ end
52
+
53
+ def self._fetch_remote_resources(provider)
54
+ _fetch_remote_rest_apis(provider).map do |rr|
55
+ _fetch_deployments(provider, rr) .map do |deployment|
56
+ stage_name = _fetch_stage_name(provider, rr, deployment)
57
+ next unless stage_name
58
+ deployment[:_terraform_id] = deployment[:id]
59
+ deployment[:_geo_id] = "#{rr[:_geo_id]}::#{stage_name}"
60
+ deployment[:stage_name] = stage_name
61
+ deployment
62
+ end
63
+ end.flatten.compact
64
+ end
65
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "./api_gateway/helpers"
2
+
3
+ ########################################################################
4
+ # AwsCloudTrail is the +aws_api_gateway_domain_name+ terrform resource,
5
+ #
6
+ # {https://www.terraform.io/docs/providers/aws/r/aws_api_gateway_domain_name.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayDomainName < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([
13
+ :domain_name,
14
+ :certificate_name,
15
+ :certificate_body,
16
+ :certificate_chain,
17
+ :certificate_private_key
18
+ ])
19
+ }
20
+
21
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
22
+ after :initialize, -> { _geo_id -> { domain_name } }
23
+
24
+ def support_tags?
25
+ false
26
+ end
27
+ end
@@ -0,0 +1,58 @@
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_integration.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayIntegration < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([
13
+ :rest_api_id,
14
+ :resource_id,
15
+ :http_method,
16
+ :type
17
+ ])
18
+ }
19
+
20
+ after :initialize, -> { self.rest_api_id = _rest_api.to_ref }
21
+ after :initialize, -> { _rest_api.api_resources[self.type][self.id] = self }
22
+
23
+ after :initialize, -> { self.resource_id = _resource.to_ref }
24
+ after :initialize, -> { depends_on [_rest_api, _resource].map(&:terraform_name) }
25
+
26
+ after :initialize, -> {
27
+ _geo_id -> {
28
+ "#{_rest_api._geo_id}::#{_resource._geo_id}::#{http_method}"
29
+ } }
30
+
31
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
32
+
33
+ def to_terraform_state
34
+ tfstate = super
35
+ tfstate[:primary][:attributes] = {
36
+ "rest_api_id" => _rest_api._terraform_id,
37
+ "resource_id" => _resource._terraform_id,
38
+ "http_method" => http_method,
39
+ "integration_http_method" => integration_http_method
40
+ }
41
+ tfstate
42
+ end
43
+
44
+ def support_tags?
45
+ false
46
+ end
47
+
48
+ def self._fetch_remote_resources(provider)
49
+ _remote_rest_api_resource_method(provider) do |rr, res, meth|
50
+ api_integration = self._fetch_integration(provider, rr, res, meth)
51
+ next nil if api_integration.nil?
52
+
53
+ api_integration[:_terraform_id] = "agi-#{rr[:_terraform_id]}-#{res[:_terraform_id]}-#{meth}"
54
+ api_integration[:_geo_id] = "#{rr[:_geo_id]}::#{res[:_geo_id]}::#{meth}"
55
+ api_integration
56
+ end.flatten.compact
57
+ end
58
+ end
@@ -0,0 +1,68 @@
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_integration_response.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayIntegrationResponse < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([
13
+ :rest_api_id,
14
+ :resource_id,
15
+ :http_method,
16
+ :status_code
17
+ ])
18
+ }
19
+
20
+ after :initialize, -> { self.rest_api_id = _rest_api.to_ref }
21
+ after :initialize, -> { _rest_api.api_resources[self.type][self.id] = self }
22
+
23
+ after :initialize, -> { self.resource_id = _resource.to_ref }
24
+ after :initialize, -> { depends_on [_rest_api, _resource].map(&:terraform_name) }
25
+
26
+ after :initialize, -> {
27
+ _geo_id -> {
28
+ [
29
+ _rest_api[:_geo_id],
30
+ _resource[:_geo_id],
31
+ http_method,
32
+ status_code
33
+ ].join("::")
34
+ }
35
+ }
36
+
37
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
38
+
39
+ def to_terraform_state
40
+ tfstate = super
41
+ tfstate[:primary][:attributes] = {
42
+ "rest_api_id" => _rest_api._terraform_id,
43
+ "resource_id" => _resource._terraform_id,
44
+ "http_method" => http_method,
45
+ "status_code" => status_code
46
+ }
47
+ tfstate
48
+ end
49
+
50
+ def support_tags?
51
+ false
52
+ end
53
+
54
+ def self._fetch_remote_resources(provider)
55
+ _remote_rest_api_resource_method(provider) do |rr, res, meth|
56
+ api_integration = self._fetch_integration(provider, rr, res, meth)
57
+ next nil if api_integration.nil?
58
+
59
+ (api_integration[:integration_responses] || {}).keys.map do |status_code|
60
+ agir = {}
61
+ tr_id = "agir-#{rr[:_terraform_id]}-#{res[:_terraform_id]}-#{meth}-#{status_code}"
62
+ agir[:_terraform_id] = tr_id
63
+ agir[:_geo_id] = "#{rr[:_geo_id]}::#{res[:_geo_id]}::#{meth}::#{status_code}"
64
+ agir
65
+ end
66
+ end.flatten.compact
67
+ end
68
+ end
@@ -0,0 +1,59 @@
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_method.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayMethod < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([
13
+ :rest_api_id,
14
+ :resource_id,
15
+ :http_method,
16
+ :authorization
17
+ ])
18
+ }
19
+
20
+ # Must pass the rest_api as _rest_api resource for additional information
21
+ after :initialize, -> { self.rest_api_id = _rest_api.to_ref }
22
+ after :initialize, -> { _rest_api.api_resources[self.type][self.id] = self }
23
+
24
+ after :initialize, -> { self.resource_id = _resource.to_ref }
25
+ after :initialize, -> { depends_on [_rest_api, _resource].map(&:terraform_name) }
26
+
27
+ after :initialize, -> {
28
+ _geo_id -> {
29
+ "#{_rest_api._geo_id}::#{_resource._geo_id}::#{http_method}"
30
+ } }
31
+
32
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
33
+
34
+ def to_terraform_state
35
+ tfstate = super
36
+ tfstate[:primary][:attributes] = {
37
+ "rest_api_id" => _rest_api._terraform_id,
38
+ "resource_id" => _resource._terraform_id,
39
+ "http_method" => http_method,
40
+ "authorization" => authorization
41
+ }
42
+ tfstate
43
+ end
44
+
45
+ def support_tags?
46
+ false
47
+ end
48
+
49
+ def self._fetch_remote_resources(provider)
50
+ _remote_rest_api_resource_method(provider) do |rr, res, meth|
51
+ api_method = self._fetch_method(provider, rr, res, meth)
52
+ next nil if api_method.nil?
53
+
54
+ api_method[:_terraform_id] = "agm-#{rr[:_terraform_id]}-#{res[:_terraform_id]}-#{meth}"
55
+ api_method[:_geo_id] = "#{rr[:_geo_id]}::#{res[:_geo_id]}::#{meth}"
56
+ api_method
57
+ end.flatten.compact
58
+ end
59
+ end
@@ -0,0 +1,69 @@
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_method_response.html}
7
+ ########################################################################
8
+ class GeoEngineer::Resources::AwsApiGatewayMethodResponse < GeoEngineer::Resource
9
+ include GeoEngineer::ApiGatewayHelpers
10
+
11
+ validate -> {
12
+ validate_required_attributes([
13
+ :rest_api_id,
14
+ :resource_id,
15
+ :http_method,
16
+ :status_code
17
+ ])
18
+ }
19
+
20
+ # Must pass the rest_api as _rest_api resource for additional information
21
+ after :initialize, -> { self.rest_api_id = _rest_api.to_ref }
22
+ after :initialize, -> { _rest_api.api_resources[self.type][self.id] = self }
23
+
24
+ after :initialize, -> { self.resource_id = _resource.to_ref }
25
+ after :initialize, -> { depends_on [_rest_api, _resource].map(&:terraform_name) }
26
+
27
+ after :initialize, -> {
28
+ _geo_id -> {
29
+ [
30
+ _rest_api._geo_id,
31
+ _resource._geo_id,
32
+ http_method,
33
+ status_code
34
+ ].join("::")
35
+ }
36
+ }
37
+
38
+ after :initialize, -> { _terraform_id -> { NullObject.maybe(remote_resource)._terraform_id } }
39
+
40
+ def to_terraform_state
41
+ tfstate = super
42
+ tfstate[:primary][:attributes] = {
43
+ "rest_api_id" => _rest_api._terraform_id,
44
+ "resource_id" => _resource._terraform_id,
45
+ "http_method" => http_method,
46
+ "status_code" => status_code
47
+ }
48
+ tfstate
49
+ end
50
+
51
+ def support_tags?
52
+ false
53
+ end
54
+
55
+ def self._fetch_remote_resources(provider)
56
+ _remote_rest_api_resource_method(provider) do |rr, res, meth|
57
+ api_method = self._fetch_method(provider, rr, res, meth)
58
+ next nil if api_method.nil?
59
+
60
+ (api_method[:method_responses] || {}).keys.map do |status_code|
61
+ agmr = {}
62
+ tf_id = "agmr-#{rr[:_terraform_id]}-#{res[:_terraform_id]}-#{meth}-#{status_code}"
63
+ agmr[:_terraform_id] = tf_id
64
+ agmr[:_geo_id] = "#{rr[:_geo_id]}::#{res[:_geo_id]}::#{meth}::#{status_code}"
65
+ agmr
66
+ end
67
+ end.flatten.compact
68
+ end
69
+ end