Class: Convection::Model::Template
- Inherits:
-
Object
- Object
- Convection::Model::Template
- Includes:
- DSL::IntrinsicFunctions, DSL::Template
- Defined in:
- lib/convection/model/template.rb,
lib/convection/model/template/output.rb,
lib/convection/model/template/mapping.rb,
lib/convection/model/template/metadata.rb,
lib/convection/model/template/resource.rb,
lib/convection/model/template/condition.rb,
lib/convection/model/template/parameter.rb,
lib/convection/model/template/resource/aws_elb.rb,
lib/convection/model/template/resource_property.rb,
lib/convection/model/template/resource_attribute.rb,
lib/convection/model/template/resource_collection.rb,
lib/convection/model/template/resource/aws_ec2_eip.rb,
lib/convection/model/template/resource/aws_ec2_vpc.rb,
lib/convection/model/template/resource/aws_kms_key.rb,
lib/convection/model/template/resource/aws_iam_role.rb,
lib/convection/model/template/resource/aws_iam_user.rb,
lib/convection/model/template/resource/aws_ec2_route.rb,
lib/convection/model/template/resource/aws_iam_group.rb,
lib/convection/model/template/resource/aws_s3_bucket.rb,
lib/convection/model/template/resource/aws_sns_topic.rb,
lib/convection/model/template/resource/aws_sqs_queue.rb,
lib/convection/model/template/resource/aws_ec2_subnet.rb,
lib/convection/model/template/resource/aws_ec2_volume.rb,
lib/convection/model/template/resource/aws_iam_policy.rb,
lib/convection/model/template/resource/aws_events_rule.rb,
lib/convection/model/template/resource/aws_ec2_instance.rb,
lib/convection/model/template/resource/aws_lambda_alias.rb,
lib/convection/model/template/resource/aws_logs_loggroup.rb,
lib/convection/model/template/resource/aws_dynamodb_table.rb,
lib/convection/model/template/resource/aws_ec2_spot_fleet.rb,
lib/convection/model/template/resource/aws_ecr_repository.rb,
lib/convection/model/template/resource/aws_elbv2_listener.rb,
lib/convection/model/template/resource/aws_iam_access_key.rb,
lib/convection/model/template/resource/aws_lambda_version.rb,
lib/convection/model/template/resource/aws_rds_db_cluster.rb,
lib/convection/model/template/resource/aws_ec2_nat_gateway.rb,
lib/convection/model/template/resource/aws_ec2_network_acl.rb,
lib/convection/model/template/resource/aws_ec2_route_table.rb,
lib/convection/model/template/resource/aws_ec2_vpn_gateway.rb,
lib/convection/model/template/resource/aws_efs_file_system.rb,
lib/convection/model/template/resource/aws_lambda_function.rb,
lib/convection/model/template/resource/aws_rds_db_instance.rb,
lib/convection/model/template/resource/aws_ec2_dhcp_options.rb,
lib/convection/model/template/resource/aws_ec2_vpc_endpoint.rb,
lib/convection/model/template/resource/aws_efs_mount_target.rb,
lib/convection/model/template/resource/aws_s3_bucket_policy.rb,
lib/convection/model/template/resource/aws_sns_subscription.rb,
lib/convection/model/template/resource/aws_sns_topic_policy.rb,
lib/convection/model/template/resource/aws_sqs_queue_policy.rb,
lib/convection/model/template/resource/aws_api_gateway_model.rb,
lib/convection/model/template/resource/aws_api_gateway_stage.rb,
lib/convection/model/template/resource/aws_cloud_watch_alarm.rb,
lib/convection/model/template/resource/aws_lambda_permission.rb,
lib/convection/model/template/resource/aws_route53_recordset.rb,
lib/convection/model/template/resource/aws_api_gateway_method.rb,
lib/convection/model/template/resource/aws_ec2_security_group.rb,
lib/convection/model/template/resource/aws_ec2_vpn_connection.rb,
lib/convection/model/template/resource/aws_elbv2_target_group.rb,
lib/convection/model/template/resource/aws_iam_managed_policy.rb,
lib/convection/model/template/resource/aws_api_gateway_account.rb,
lib/convection/model/template/resource/aws_api_gateway_api_key.rb,
lib/convection/model/template/resource/aws_ec2_eip_association.rb,
lib/convection/model/template/resource/aws_elasticache_cluster.rb,
lib/convection/model/template/resource/aws_elbv2_listener_rule.rb,
lib/convection/model/template/resource/aws_elbv2_load_balancer.rb,
lib/convection/model/template/resource/aws_rds_db_subnet_group.rb,
lib/convection/model/template/resource/aws_route53_hosted_zone.rb,
lib/convection/model/template/resource_attribute/update_policy.rb,
lib/convection/model/template/resource/aws_api_gateway_resource.rb,
lib/convection/model/template/resource/aws_api_gateway_rest_api.rb,
lib/convection/model/template/resource/aws_ec2_customer_gateway.rb,
lib/convection/model/template/resource/aws_ec2_internet_gateway.rb,
lib/convection/model/template/resource/aws_elasticsearch_domain.rb,
lib/convection/model/template/resource/aws_iam_instance_profile.rb,
lib/convection/model/template/resource/aws_route53_health_check.rb,
lib/convection/model/template/resource/aws_ec2_network_acl_entry.rb,
lib/convection/model/template/resource/aws_rds_db_security_group.rb,
lib/convection/model/template/resource/aws_api_gateway_authorizer.rb,
lib/convection/model/template/resource/aws_api_gateway_deployment.rb,
lib/convection/model/template/resource/aws_api_gateway_usage_plan.rb,
lib/convection/model/template/resource/aws_rds_db_parameter_group.rb,
lib/convection/model/template/resource/aws_rds_event_subscription.rb,
lib/convection/model/template/resource/aws_cloudfront_distribution.rb,
lib/convection/model/template/resource/aws_ec2_vpn_connection_route.rb,
lib/convection/model/template/resource/aws_elasticache_subnet_group.rb,
lib/convection/model/template/resource/aws_logs_subscription_filter.rb,
lib/convection/model/template/resource_property/aws_ec2_mount_point.rb,
lib/convection/model/template/resource/aws_ec2_security_group_ingres.rb,
lib/convection/model/template/resource/aws_api_gateway_usage_plan_key.rb,
lib/convection/model/template/resource/aws_ec2_vpc_gateway_attachment.rb,
lib/convection/model/template/resource/aws_ec2_vpc_peering_connection.rb,
lib/convection/model/template/resource/aws_elasticache_security_group.rb,
lib/convection/model/template/resource_property/aws_cloudfront_origin.rb,
lib/convection/model/template/resource_property/aws_lambda_vpc_config.rb,
lib/convection/model/template/resource/aws_auto_scaling_scaling_policy.rb,
lib/convection/model/template/resource/aws_directory_service_simple_ad.rb,
lib/convection/model/template/resource/aws_elasticache_parameter_group.rb,
lib/convection/model/template/resource_property/aws_cloudfront_logging.rb,
lib/convection/model/template/resource_property/aws_events_rule_target.rb,
lib/convection/model/template/resource_property/aws_lambda_environment.rb,
lib/convection/model/template/resource/aws_elasticbeanstalk_application.rb,
lib/convection/model/template/resource/aws_elasticbeanstalk_environment.rb,
lib/convection/model/template/resource/aws_rds_db_clusterparametergroup.rb,
lib/convection/model/template/resource_property/aws_cloudfront_s3origin.rb,
lib/convection/model/template/resource_property/aws_route53_geolocation.rb,
lib/convection/model/template/resource/aws_api_gateway_base_path_mapping.rb,
lib/convection/model/template/resource/aws_auto_scaling_scheduled_action.rb,
lib/convection/model/template/resource/aws_elasticache_replication_group.rb,
lib/convection/model/template/resource_property/aws_lambda_function_code.rb,
lib/convection/model/template/resource_property/aws_route53_alias_target.rb,
lib/convection/model/template/resource/aws_api_gateway_client_certificate.rb,
lib/convection/model/template/resource_property/aws_ec2_network_interface.rb,
lib/convection/model/template/resource_property/aws_s3_cors_configuration.rb,
lib/convection/model/template/resource/aws_auto_scaling_auto_scaling_group.rb,
lib/convection/model/template/resource/aws_certificate_manager_certificate.rb,
lib/convection/model/template/resource_property/aws_cloudfront_customorigin.rb,
lib/convection/model/template/resource_property/aws_cloudfront_restrictions.rb,
lib/convection/model/template/resource/aws_auto_scaling_launch_configuration.rb,
lib/convection/model/template/resource/aws_ec2_vpn_gateway_route_propagation.rb,
lib/convection/model/template/resource_property/aws_cloudfront_cachebehavior.rb,
lib/convection/model/template/resource_property/aws_ec2_block_device_mapping.rb,
lib/convection/model/template/resource_property/aws_ec2_iam_instance_profile.rb,
lib/convection/model/template/resource_property/aws_s3_website_configuration.rb,
lib/convection/model/template/resource/aws_ec2_subnet_network_acl_association.rb,
lib/convection/model/template/resource/aws_ec2_subnet_route_table_association.rb,
lib/convection/model/template/resource/aws_elasticache_security_group_ingress.rb,
lib/convection/model/template/resource_property/aws_cloudfront_georestriction.rb,
lib/convection/model/template/resource/aws_elasticbeanstalk_applicationversion.rb,
lib/convection/model/template/resource_property/aws_cloudfront_forwardedvalues.rb,
lib/convection/model/template/resource_property/aws_elbv2_listener_rule_action.rb,
lib/convection/model/template/resource_property/aws_elbv2_target_group_matcher.rb,
lib/convection/model/template/resource_property/aws_s3_cors_configuration_rule.rb,
lib/convection/model/template/resource_property/aws_elbv2_listener_certificates.rb,
lib/convection/model/template/resource_property/aws_cloudfront_viewercertificate.rb,
lib/convection/model/template/resource_property/aws_ec2_block_store_block_device.rb,
lib/convection/model/template/resource_property/aws_elbv2_target_group_attribute.rb,
lib/convection/model/template/resource_property/aws_s3_replication_configuration.rb,
lib/convection/model/template/resource/aws_elasticbeanstalk_configurationtemplate.rb,
lib/convection/model/template/resource_property/aws_api_gateway_api_key_stage_key.rb,
lib/convection/model/template/resource_property/aws_elbv2_listener_default_action.rb,
lib/convection/model/template/resource_property/aws_elbv2_listener_rule_condition.rb,
lib/convection/model/template/resource_property/aws_elbv2_load_balancer_attribute.rb,
lib/convection/model/template/resource_property/aws_api_gateway_method_integration.rb,
lib/convection/model/template/resource_property/aws_cloudfront_customerrorresponse.rb,
lib/convection/model/template/resource_property/aws_cloudfront_distribution_config.rb,
lib/convection/model/template/resource_property/aws_cloudfront_defaultcachebehavior.rb,
lib/convection/model/template/resource_property/aws_api_gateway_rest_api_s3_location.rb,
lib/convection/model/template/resource_property/aws_api_gateway_usage_plan_api_stage.rb,
lib/convection/model/template/resource_property/aws_elasticsearch_domain_ebs_options.rb,
lib/convection/model/template/resource_property/aws_elasticsearch_domain_vpc_options.rb,
lib/convection/model/template/resource_property/aws_s3_replication_configuration_rule.rb,
lib/convection/model/template/resource_property/aws_api_gateway_method_method_response.rb,
lib/convection/model/template/resource_property/aws_cloudfront_forwardedvalues_cookies.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data.rb,
lib/convection/model/template/resource_property/aws_lambda_function_dead_letter_config.rb,
lib/convection/model/template/resource_property/aws_api_gateway_usage_plan_quota_settings.rb,
lib/convection/model/template/resource_property/aws_elasticsearch_domain_advanced_options.rb,
lib/convection/model/template/resource_property/aws_elasticsearch_domain_snapshot_options.rb,
lib/convection/model/template/resource_property/aws_elbv2_target_group_target_description.rb,
lib/convection/model/template/resource_property/aws_s3_website_configuration_routing_rule.rb,
lib/convection/model/template/resource_property/aws_api_gateway_deployment_stage_description.rb,
lib/convection/model/template/resource_property/aws_api_gateway_usage_plan_throttle_settings.rb,
lib/convection/model/template/resource_property/aws_api_gateway_deployment_stage_method_setting.rb,
lib/convection/model/template/resource_property/aws_s3_replication_configuration_rule_destination.rb,
lib/convection/model/template/resource_property/aws_elasticsearch_domain_elasticsearch_cluster_config.rb,
lib/convection/model/template/resource_property/aws_s3_website_configuration_redirect_all_requests_to.rb,
lib/convection/model/template/resource_property/aws_api_gateway_method_integration_integration_response.rb,
lib/convection/model/template/resource_property/aws_s3_website_configuration_routing_rule_redirect_rule.rb,
lib/convection/model/template/resource_property/aws_elasticache_replication_group_node_group_configuration.rb,
lib/convection/model/template/resource_property/aws_api_gateway_deployment_stage_description_method_setting.rb,
lib/convection/model/template/resource_property/aws_certificate_manager_certificate_domain_validation_option.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data_launch_specifications.rb,
lib/convection/model/template/resource_property/aws_s3_website_configuration_routing_rule_routing_rule_condition.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data_launch_specifications_security_groups.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data_launch_specifications_network_interface.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data_launch_specifications_block_device_mapping.rb,
lib/convection/model/template/resource_property/aws_ec2_spot_fleet_request_config_data_launch_specifications_block_device_mapping_ebs.rb
Overview
Template container class
Defined Under Namespace
Classes: Condition, Mapping, Metadata, Output, Parameter, Resource, ResourceAttribute, ResourceCollection, ResourceProperty
Constant Summary collapse
- DEFAULT_VERSION =
'2010-09-09'.freeze
Constants included from DSL::Template
DSL::Template::CF_MAX_BYTESIZE, DSL::Template::CF_MAX_DESCRIPTION_BYTESIZE, DSL::Template::CF_MAX_MAPPINGS, DSL::Template::CF_MAX_MAPPING_ATTRIBUTES, DSL::Template::CF_MAX_MAPPING_ATTRIBUTE_NAME, DSL::Template::CF_MAX_MAPPING_NAME, DSL::Template::CF_MAX_OUTPUTS, DSL::Template::CF_MAX_OUTPUT_NAME_CHARACTERS, DSL::Template::CF_MAX_PARAMETERS, DSL::Template::CF_MAX_PARAMETER_NAME_CHARACTERS, DSL::Template::CF_MAX_PARAMETER_VALUE_BYTESIZE, DSL::Template::CF_MAX_RESOURCES, DSL::Template::CF_MAX_RESOURCE_NAME
Instance Attribute Summary collapse
-
#attribute_mappings ⇒ Object
readonly
Returns the value of attribute attribute_mappings.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#resource_collections ⇒ Object
readonly
Returns the value of attribute resource_collections.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
- #all_resources ⇒ Object
- #clone(stack_) ⇒ Object
- #diff(other, stack_ = nil, retain: false) ⇒ Object
- #execute ⇒ Object
-
#initialize(stack = nil, &block) ⇒ Template
constructor
A new instance of Template.
- #render(stack_ = nil, retain: false) ⇒ Object
- #template ⇒ Object
- #to_json(stack_ = nil, pretty = false, retain: false) ⇒ Object
- #validate(rendered_stack = nil) ⇒ Object
- #validate_bytesize(rendered_stack) ⇒ Object
- #validate_compare(value, cf_max, error) ⇒ Object
- #validate_description(rendered_stack) ⇒ Object
- #validate_mappings(rendered_stack) ⇒ Object
- #validate_outputs(rendered_stack) ⇒ Object
- #validate_parameters(rendered_stack) ⇒ Object
- #validate_resources(rendered_stack) ⇒ Object
Methods included from DSL::Template
#condition, #logs_log_group, #mapping, #metadata, #output, #parameter, #resource
Methods included from DSL::Template::Resource
#_terraform_module_dir_to_flag, #_terraform_module_flag_to_dir, attach_resource, attach_resource_collection, resource_collection_dsl_methods, resource_dsl_methods
Methods included from DSL::Helpers
#camel_case, included, method_name, #screaming_snake_case, #snake_case
Methods included from DSL::IntrinsicFunctions
#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_import_value, #fn_not, #fn_or, #fn_ref, #fn_sub, #get_att, #get_azs, included, #join, mixers, #select
Constructor Details
#initialize(stack = nil, &block) ⇒ Template
Returns a new instance of Template.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/convection/model/template.rb', line 239 def initialize(stack = nil, &block) @definition = block @stack = stack @attribute_mappings = {} @version = DEFAULT_VERSION @description = '' @parameters = Collection.new @mappings = Collection.new @conditions = Collection.new @resources = Collection.new @resource_collections = Collection.new @outputs = Collection.new @metadata = Collection.new end |
Instance Attribute Details
#attribute_mappings ⇒ Object (readonly)
Returns the value of attribute attribute_mappings.
226 227 228 |
# File 'lib/convection/model/template.rb', line 226 def attribute_mappings @attribute_mappings end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
230 231 232 |
# File 'lib/convection/model/template.rb', line 230 def conditions @conditions end |
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
229 230 231 |
# File 'lib/convection/model/template.rb', line 229 def mappings @mappings end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
233 234 235 |
# File 'lib/convection/model/template.rb', line 233 def outputs @outputs end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
228 229 230 |
# File 'lib/convection/model/template.rb', line 228 def parameters @parameters end |
#resource_collections ⇒ Object (readonly)
Returns the value of attribute resource_collections.
231 232 233 |
# File 'lib/convection/model/template.rb', line 231 def resource_collections @resource_collections end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
232 233 234 |
# File 'lib/convection/model/template.rb', line 232 def resources @resources end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
225 226 227 |
# File 'lib/convection/model/template.rb', line 225 def stack @stack end |
Instance Method Details
#all_resources ⇒ Object
293 294 295 296 297 |
# File 'lib/convection/model/template.rb', line 293 def all_resources resource_collections.reduce(resources) do |result, (_name, resource_collection)| result.merge(resource_collection.resources) end end |
#clone(stack_) ⇒ Object
257 258 259 |
# File 'lib/convection/model/template.rb', line 257 def clone(stack_) Template.new(stack_, &@definition) end |
#diff(other, stack_ = nil, retain: false) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/convection/model/template.rb', line 299 def diff(other, stack_ = nil, retain: false) # We want to accurately show when the DeletionPolicy is getting deleted and also when resources are going to be retained. # Sample DeletionPolicy Removal output # us-east-1 compare Compare local state of stack test-logs-deletion with remote template # us-east-1 delete Resources.sgtestConvectionDeletion.DeletionPolicy # # Sample Mixed Retain/Delete Resources # us-east-1 retain Resources.ELBLoggingPolicy.DependsOn.AWS::S3::BucketPolicy.0 # us-east-1 retain Resources.ELBLoggingPolicy.DeletionPolicy # us-east-1 delete Resources.sgtestConvectionDeletion.Type # us-east-1 delete Resources.sgtestConvectionDeletion.Properties.AWS::EC2::SecurityGroup.GroupDescription # us-east-1 delete Resources.sgtestConvectionDeletion.Properties.AWS::EC2::SecurityGroup.VpcId # events = render(stack_, retain: retain).diff(other).map { |diff| Diff.new(diff[0], *diff[1]) } # Top level events (changes to the resource directly) have keys with a format "Resources.{NAME}.{KEY}". # So we can count the number of separators to find them. top_level_events = events.select { |event| event.key.count('.') <= 2 } # We know something's a deleted resource when it has a top level "Type" attribute. type_suffix = '.Type'.freeze deleted_resources = top_level_events.select do |event| event.action == :delete && event.key.end_with?(type_suffix) end deleted_resources.map! { |event| event.key[0...-type_suffix.length] } # We know something's a retainable resource when it has a top level "DeletionPolicy" attribute. delete_policy_suffix = '.DeletionPolicy'.freeze retainable_resources = top_level_events.select do |event| event.action == :delete && event.key.end_with?(delete_policy_suffix) && event.theirs == 'Retain' end retainable_resources.map! { |event| event.key[0...-delete_policy_suffix.length] } retainable_resources.keep_if { |name| deleted_resources.include?(name) } events.each do |event| retained = retainable_resources.any? { |name| event.action == :delete && event.key.start_with?(name) } event.action = :retain if retained end events end |
#execute ⇒ Object
261 262 263 264 265 266 267 268 |
# File 'lib/convection/model/template.rb', line 261 def execute instance_exec(&@definition) resource_collections.each do |_, group| group.run_definition group.execute end end |
#render(stack_ = nil, retain: false) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/convection/model/template.rb', line 270 def render(stack_ = nil, retain: false) ## Instantiate a new template with the definition block and an other stack return clone(stack_).render unless stack_.nil? execute ## Process the template document { 'AWSTemplateFormatVersion' => version, 'Description' => description, 'Parameters' => parameters.map(&:render), 'Mappings' => mappings.map(&:render), 'Conditions' => conditions.map(&:render), 'Resources' => all_resources.map do |resource| if retain && resource.deletion_policy.nil? resource.deletion_policy('Retain') end resource.render end, 'Outputs' => outputs.map(&:render), 'Metadata' => .map(&:render) } end |
#template ⇒ Object
235 236 237 |
# File 'lib/convection/model/template.rb', line 235 def template self end |
#to_json(stack_ = nil, pretty = false, retain: false) ⇒ Object
341 342 343 344 345 346 |
# File 'lib/convection/model/template.rb', line 341 def to_json(stack_ = nil, pretty = false, retain: false) rendered_stack = render(stack_, retain: retain) validate(rendered_stack) return JSON.generate(rendered_stack) unless pretty JSON.pretty_generate(rendered_stack) end |
#validate(rendered_stack = nil) ⇒ Object
348 349 350 351 352 |
# File 'lib/convection/model/template.rb', line 348 def validate(rendered_stack = nil) %w(resources mappings parameters outputs description bytesize).map do |method| send("validate_#{method}", rendered_stack) end end |
#validate_bytesize(rendered_stack) ⇒ Object
437 438 439 440 441 442 |
# File 'lib/convection/model/template.rb', line 437 def validate_bytesize(rendered_stack) json = JSON.generate(rendered_stack) validate_compare(json.bytesize, CF_MAX_BYTESIZE, ExcessiveTemplateSizeError) end |
#validate_compare(value, cf_max, error) ⇒ Object
354 355 356 |
# File 'lib/convection/model/template.rb', line 354 def validate_compare(value, cf_max, error) limit_exceeded_error(value, cf_max, error) if value > cf_max end |
#validate_description(rendered_stack) ⇒ Object
431 432 433 434 435 |
# File 'lib/convection/model/template.rb', line 431 def validate_description(rendered_stack) validate_compare(rendered_stack['Description'].bytesize, CF_MAX_DESCRIPTION_BYTESIZE, ExcessiveDescriptionError) end |
#validate_mappings(rendered_stack) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/convection/model/template.rb', line 369 def validate_mappings(rendered_stack) mappings = rendered_stack ['Mappings'] validate_compare(mappings.count, CF_MAX_MAPPINGS, ExcessiveMappingsError) mappings.each do |_, value| validate_compare( value.count, CF_MAX_MAPPING_ATTRIBUTES, ExcessiveMappingAttributesError ) end mappings.keys.each do |key| validate_compare(key.length, CF_MAX_MAPPING_NAME, ExcessiveMappingNameError) end ## XXX What are we trying to do here @aburke mapping_attributes = mappings.values.flat_map do |inner_hash| inner_hash.keys.select do |key| value = inner_hash[key] end end mapping_attributes.each do |attribute| validate_compare(attribute.length, CF_MAX_MAPPING_ATTRIBUTE_NAME, ExcessiveMappingAttributeNameError) end end |
#validate_outputs(rendered_stack) ⇒ Object
419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/convection/model/template.rb', line 419 def validate_outputs(rendered_stack) outputs = rendered_stack['Outputs'] validate_compare(outputs.count, CF_MAX_OUTPUTS, ExcessiveOutputsError) largest_output_name = outputs.keys.max largest_output_name ||= '' validate_compare(largest_output_name.length, CF_MAX_OUTPUT_NAME_CHARACTERS, ExcessiveOutputNameError) end |
#validate_parameters(rendered_stack) ⇒ Object
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/convection/model/template.rb', line 402 def validate_parameters(rendered_stack) parameters = rendered_stack['Parameters'] validate_compare(parameters.count, CF_MAX_PARAMETERS, ExcessiveParametersError) largest_parameter_name = parameters.keys.max largest_parameter_name ||= '' validate_compare(largest_parameter_name.length, CF_MAX_PARAMETER_NAME_CHARACTERS, ExcessiveParameterNameError) parameters.values.each do |value| validate_compare(JSON.generate(value).bytesize, CF_MAX_PARAMETER_VALUE_BYTESIZE, ExcessiveParameterBytesizeError) end end |
#validate_resources(rendered_stack) ⇒ Object
358 359 360 361 362 363 364 365 366 367 |
# File 'lib/convection/model/template.rb', line 358 def validate_resources(rendered_stack) validate_compare(rendered_stack['Resources'].count, CF_MAX_RESOURCES, ExcessiveResourcesError) largest_resource_name = resources.keys.max || '' validate_compare(largest_resource_name.length, CF_MAX_RESOURCE_NAME, ExcessiveResourceNameError) end |