Module: Skywriter::Resource
- Included in:
- AutoScaling::AutoScalingGroup, AutoScaling::LaunchConfiguration, AutoScaling::ScalingPolicy, AutoScaling::ScheduledAction, AutoScaling::Trigger, CloudFormation::Authentication, CloudFormation::CustomResource, CloudFormation::Stack, CloudFormation::WaitCondition, CloudFormation::WaitConditionHandle, CloudFront::Distribution, CloudWatch::Alarm, DynamoDB::Table, EC2::CustomerGateway, EC2::DHCPOptions, EC2::EIP, EC2::EIPAssociation, EC2::Instance, EC2::InternetGateway, EC2::NetworkAcl, EC2::NetworkAclEntry, EC2::NetworkInterface, EC2::NetworkInterfaceAttachment, EC2::Route, EC2::RouteTable, EC2::SecurityGroup, EC2::SecurityGroupEgress, EC2::SecurityGroupIngress, EC2::Subnet, EC2::SubnetNetworkAclAssociation, EC2::SubnetRouteTableAssociation, EC2::VPC, EC2::VPCDHCPOptionsAssociation, EC2::VPCGatewayAttachment, EC2::VPNConnection, EC2::VPNConnectionRoute, EC2::VPNGateway, EC2::VPNGatewayRoutePropagation, EC2::Volume, EC2::VolumeAttachment, ElastiCache::CacheCluster, ElastiCache::ParameterGroup, ElastiCache::SecurityGroup, ElastiCache::SecurityGroupIngress, ElastiCache::SubnetGroup, ElasticBeanstalk::Application, ElasticBeanstalk::ApplicationVersion, ElasticBeanstalk::ConfigurationTemplate, ElasticBeanstalk::Environment, ElasticLoadBalancing::LoadBalancer, IAM::AccessKey, IAM::Group, IAM::InstanceProfile, IAM::Policy, IAM::Role, IAM::User, IAM::UserToGroupAddition, RDS::DBInstance, RDS::DBParameterGroup, RDS::DBSecurityGroup, RDS::DBSecurityGroupIngress, RDS::DBSubnetGroup, Redshift::Cluster, Redshift::ClusterParameterGroup, Redshift::ClusterSecurityGroup, Redshift::ClusterSecurityGroupIngress, Redshift::ClusterSubnetGroup, Route53::RecordSet, Route53::RecordSetGroup, S3::Bucket, S3::BucketPolicy, SDB::Domain, SNS::Topic, SNS::TopicPolicy, SQS::Queue, SQS::QueuePolicy
- Defined in:
- lib/skywriter/resource.rb,
lib/skywriter/resource/ec2/eip.rb,
lib/skywriter/resource/ec2/vpc.rb,
lib/skywriter/resource/pointer.rb,
lib/skywriter/resource/iam/role.rb,
lib/skywriter/resource/iam/user.rb,
lib/skywriter/resource/ec2/route.rb,
lib/skywriter/resource/iam/group.rb,
lib/skywriter/resource/s3/bucket.rb,
lib/skywriter/resource/sns/topic.rb,
lib/skywriter/resource/sqs/queue.rb,
lib/skywriter/resource/ec2/subnet.rb,
lib/skywriter/resource/ec2/volume.rb,
lib/skywriter/resource/iam/policy.rb,
lib/skywriter/resource/sdb/domain.rb,
lib/skywriter/resource/ref_pointer.rb,
lib/skywriter/resource/ec2/instance.rb,
lib/skywriter/resource/iam/access_key.rb,
lib/skywriter/resource/dynamo_db/table.rb,
lib/skywriter/resource/ec2/network_acl.rb,
lib/skywriter/resource/ec2/route_table.rb,
lib/skywriter/resource/ec2/vpn_gateway.rb,
lib/skywriter/resource/rds/db_instance.rb,
lib/skywriter/resource/ec2/dhcp_options.rb,
lib/skywriter/resource/redshift/cluster.rb,
lib/skywriter/resource/s3/bucket_policy.rb,
lib/skywriter/resource/sns/topic_policy.rb,
lib/skywriter/resource/sqs/queue_policy.rb,
lib/skywriter/resource/cloud_watch/alarm.rb,
lib/skywriter/resource/ec2/security_group.rb,
lib/skywriter/resource/ec2/vpn_connection.rb,
lib/skywriter/resource/ec2/eip_association.rb,
lib/skywriter/resource/rds/db_subnet_group.rb,
lib/skywriter/resource/route_53/record_set.rb,
lib/skywriter/resource/auto_scaling/trigger.rb,
lib/skywriter/resource/ec2/customer_gateway.rb,
lib/skywriter/resource/ec2/internet_gateway.rb,
lib/skywriter/resource/iam/instance_profile.rb,
lib/skywriter/resource/logical_name_pointer.rb,
lib/skywriter/resource/cloud_formation/stack.rb,
lib/skywriter/resource/ec2/network_acl_entry.rb,
lib/skywriter/resource/ec2/network_interface.rb,
lib/skywriter/resource/ec2/volume_attachment.rb,
lib/skywriter/resource/rds/db_security_group.rb,
lib/skywriter/resource/rds/db_parameter_group.rb,
lib/skywriter/resource/cloud_front/distribution.rb,
lib/skywriter/resource/ec2/vpn_connection_route.rb,
lib/skywriter/resource/elasticache/subnet_group.rb,
lib/skywriter/resource/ec2/security_group_egress.rb,
lib/skywriter/resource/route_53/record_set_group.rb,
lib/skywriter/resource/ec2/security_group_ingress.rb,
lib/skywriter/resource/ec2/vpc_gateway_attachment.rb,
lib/skywriter/resource/elasti_cache/cache_cluster.rb,
lib/skywriter/resource/elasticache/security_group.rb,
lib/skywriter/resource/iam/user_to_group_addition.rb,
lib/skywriter/resource/auto_scaling/scaling_policy.rb,
lib/skywriter/resource/elasticache/parameter_group.rb,
lib/skywriter/resource/auto_scaling/scheduled_action.rb,
lib/skywriter/resource/elastic_beanstalk/application.rb,
lib/skywriter/resource/elastic_beanstalk/environment.rb,
lib/skywriter/resource/rds/db_security_group_ingress.rb,
lib/skywriter/resource/redshift/cluster_subnet_group.rb,
lib/skywriter/resource/cloud_formation/authentication.rb,
lib/skywriter/resource/cloud_formation/wait_condition.rb,
lib/skywriter/resource/auto_scaling/auto_scaling_group.rb,
lib/skywriter/resource/cloud_formation/custom_resource.rb,
lib/skywriter/resource/redshift/cluster_security_group.rb,
lib/skywriter/resource/ec2/network_interface_attachment.rb,
lib/skywriter/resource/ec2/vpc_dhcp_options_association.rb,
lib/skywriter/resource/redshift/cluster_parameter_group.rb,
lib/skywriter/resource/auto_scaling/launch_configuration.rb,
lib/skywriter/resource/ec2/vpn_gateway_route_propagation.rb,
lib/skywriter/resource/ec2/subnet_network_acl_association.rb,
lib/skywriter/resource/ec2/subnet_route_table_association.rb,
lib/skywriter/resource/elasticache/security_group_ingress.rb,
lib/skywriter/resource/elastic_load_balancing/load_balancer.rb,
lib/skywriter/resource/cloud_formation/wait_condition_handle.rb,
lib/skywriter/resource/elastic_beanstalk/application_version.rb,
lib/skywriter/resource/redshift/cluster_security_group_ingress.rb,
lib/skywriter/resource/elastic_beanstalk/configuration_template.rb
Defined Under Namespace
Modules: AutoScaling, CloudFormation, CloudFront, CloudWatch, DSL, DynamoDB, EC2, ElastiCache, ElasticBeanstalk, ElasticLoadBalancing, IAM, RDS, Redshift, Route53, S3, SDB, SNS, SQS Classes: LogicalNamePointer, Pointer, RefPointer
Instance Attribute Summary collapse
-
#logical_name ⇒ Object
readonly
Returns the value of attribute logical_name.
Instance Method Summary collapse
-
#[](attribute_name) ⇒ Hash
Sugar for using an attribute of this resource in another resource.
-
#as_json ⇒ Hash
Returns a hash representing the Resource.
-
#as_pointer(options = {}) ⇒ Skywriter::Resource::Pointer
Returns a pointer to this Resource.
- #initialize(logical_name, options = {}) ⇒ Object
- #register_dependency(dependency) ⇒ Object private
Instance Attribute Details
#logical_name ⇒ Object (readonly)
Returns the value of attribute logical_name.
37 38 39 |
# File 'lib/skywriter/resource.rb', line 37 def logical_name @logical_name end |
Instance Method Details
#[](attribute_name) ⇒ Hash
Sugar for using an attribute of this resource in another resource.
126 127 128 |
# File 'lib/skywriter/resource.rb', line 126 def [](attribute_name) Function.get_att(logical_name, attribute_name.to_s) end |
#as_json ⇒ Hash
Returns a hash representing the Resource
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/skywriter/resource.rb', line 63 def as_json(*) Thread.current[:skywriter_as_json_context] = self { logical_name => { 'Type' => type, 'Properties' => properties.as_json, 'DependsOn' => all_dependencies, 'Metadata' => , 'DeletionPolicy' => deletion_policy, 'UpdatePolicy' => update_policy, }.reject { |key, value| value.nil? } } ensure Thread.current[:skywriter_as_json_context] = nil end |
#as_pointer(options = {}) ⇒ Skywriter::Resource::Pointer
Returns a pointer to this Resource
Pointers represent references to resources defined elsewhere in a template. In most cases pointers serialize to something like
In some cases, you might need to refer to a resource using its logical name directly (as opposed to nested in a hash as shown), in which case you can tell ‘as_pointer` to point with the resource’s logical name:
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/skywriter/resource.rb', line 102 def as_pointer( = {}) with = [:with] || :ref case with when :ref Skywriter::Resource::RefPointer.new(self) when :logical_name Skywriter::Resource::LogicalNamePointer.new(self) else raise ArgumentError, "Unrecognized 'with' value '#{with}'" end end |
#initialize(logical_name, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/skywriter/resource.rb', line 48 def initialize(logical_name, = {}) @logical_name = logical_name @additional_dependencies = Set.new(Array(delete_liberally(, :additional_dependencies))) @deletion_policy = delete_liberally(, :deletion_policy) @metadata = delete_liberally(, :metadata) @update_policy = delete_liberally(, :update_policy) @options = .freeze end |
#register_dependency(dependency) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 |
# File 'lib/skywriter/resource.rb', line 134 def register_dependency(dependency) magical_dependencies << dependency.logical_name end |