aws_elastic_lb & aws_elastic_ip

Prishita Kapoor
2 min readApr 11, 2022

aws_elastic_lb

elastic_lb handles registering and removing nodes from ELBs. The resource also adds basic support for creating and deleting ELBs. Note that currently this resource is not fully idempotent so it will not update the existing configuration of an ELB.

Actions

  • register - Add a node to the ELB
  • deregister - Remove a node from the ELB
  • create - Create a new ELB
  • delete - Delete an existing ELB

Properties

  • aws_secret_access_key, aws_access_key and optionally aws_session_token - required, unless using IAM roles for authentication.
  • name - the name of the ELB, required.
  • region, The region of the ELB. Defaults to the region of the node.
  • listeners, Array or hashes. The ports/protocols the ELB will listen on. See the example for a sample.
  • security_groups, Array. Security groups to apply to the ELB. Only needed when creating ELBs.
  • subnets, Array. The subnets the ELB will listen in. Only needed when creating ELBs and when using VPCs.
  • availability_zones: Array. The availability zones the ELB will listen in. Only needed when creating ELBs and when using classic networking.
  • tags: Array.
  • scheme: Array.

Examples

ELB running in classic networking listening on port 80.

aws_elastic_lb 'Setup the ELB' do
name 'example-elb'
action :create
availability_zones ['us-west-2a']
listeners [
{
instance_port: 80,
instance_protocol: 'HTTP',
load_balancer_port: 80,
protocol: 'HTTP',
},
]
end

To register the node in the ‘QA’ ELB:

aws_elastic_lb 'elb_qa' do
name 'QA'
action :register
end

aws_elastic_ip

The elastic_ip resource provider does not support allocating new IPs. This must be done before running a recipe that uses the resource. After allocating a new Elastic IP, we recommend storing it in a databag and loading the item in the recipe.

Actions

  • associate - Associate an allocated IP to the node
  • disassociate - Disassociate an allocated IP from the node

Properties

  • aws_secret_access_key, aws_access_key and optionally aws_session_token - required, unless using IAM roles for authentication.
  • ip: String. The IP address to associate or disassociate.
  • timeout: Integer. Default: 180. Time in seconds to wait. 0 for unlimited.

Examples

aws_elastic_ip '34.15.30.10' do
action :associate
end
aws_elastic_ip 'Server public IP' do
ip '34.15.30.11'
action :associate
end

--

--

Prishita Kapoor

I endeavor to fuse academic knowledge with experience for the growth of the world while enhancing my engineering and interpersonal skills.