EC2-Classic
Platforms

This sample adds an Amazon ElastiCache cluster to an environment with instances launched
into the EC2-Classic platform. All of the properties that are listed in this example
are the
minimum required properties that must be set for each resource type. You can download
the
example at ElastiCache
Example.

Note

This example creates AWS resources, which you might be charged for. For more information
about AWS pricing, see
https://aws.amazon.com/pricing/. Some services are part of the AWS Free Usage Tier. If you are a new
customer, you can test drive
these services for free. See https://aws.amazon.com/free/ for more information.

To use this example, do the following:

Create an .ebextensions directory in the top-level directory of your
source bundle.

Create two configuration files with the .config extension and place them
in your .ebextensions directory. One configuration file defines the resources, and the other configuration
file defines the options.

Deploy your application to Elastic Beanstalk.

YAML relies on consistent indentation. Match the indentation level when replacing
content in an example
configuration file and ensure that your text editor uses spaces, not tab characters,
to indent.

Create a configuration file
(e.g., elasticache.config) that defines the resources. In this example,
we create the ElastiCache cluster by specifying the name of the ElastiCache cluster
resource
(MyElastiCache), declaring its type, and then configuring the properties for
the cluster. The example references the name of the ElastiCache security group resource
that
gets created and defined in this configuration file. Next, we create an ElastiCache
security
group. We define the name for this resource, declare its type, and add a description
for the
security group. Finally, we set the ingress rules for the ElastiCache security group
to allow
access only from instances inside the ElastiCache security group
(MyCacheSecurityGroup) and the Elastic Beanstalk security group
(AWSEBSecurityGroup). The parameter name, AWSEBSecurityGroup, is a
fixed resource name provided by Elastic Beanstalk. You must add
AWSEBSecurityGroup to your ElastiCache security group ingress rules in order
for your Elastic Beanstalk application to connect to the instances in your ElastiCache
cluster.

These lines tell Elastic Beanstalk to get the values for the CacheNodeType, NumCacheNodes,
and Engine properties from the CacheNodeType, NumCacheNodes, and
Engine values in a config file (options.config in our example) that contains an
option_settings section with an aws:elasticbeanstalk:customoption section
that contains a name-value pair that contains the actual value to use. In the example
above,
this means cache.m1.small, 1, and memcached would be used for the values. For more
information
about Fn::GetOptionSetting, see Functions.

EC2-VPC
(Default)

This sample adds an Amazon ElastiCache cluster to an environment with instances launched
into the EC2-VPC platform. Specifically, the information in this section applies to
a scenario
where EC2 launches instances into the default VPC. All of the properties in this example
are
the minimum required properties that must be set for each resource type. For more
information
about default VPCs, see Your Default VPC and
Subnets.

Note

This example creates AWS resources, which you might be charged for. For more information
about AWS pricing, see
https://aws.amazon.com/pricing/. Some services are part of the AWS Free Usage Tier. If you are a new
customer, you can test drive
these services for free. See https://aws.amazon.com/free/ for more information.

To use this example, do the following:

Create an .ebextensions directory in the top-level directory of your
source bundle.

Create two configuration files with the .config extension and place them
in your .ebextensions directory. One configuration file defines the resources, and the other configuration
file defines the options.

Deploy your application to Elastic Beanstalk.

YAML relies on consistent indentation. Match the indentation level when replacing
content in an example
configuration file and ensure that your text editor uses spaces, not tab characters,
to indent.

Now name the resources
configuration file elasticache.config. To create the ElastiCache cluster,
this example specifies the name of the ElastiCache cluster resource
(MyElastiCache), declares its type, and then configures the properties for the
cluster. The example references the ID of the security group resource that we create
and
define in this configuration file.

Next, we create an EC2 security group. We define the name for this resource, declare
its
type, add a description, and set the ingress rules for the security group to allow
access only
from instances inside the Elastic Beanstalk security group (AWSEBSecurityGroup).
(The parameter name, AWSEBSecurityGroup, is a fixed resource name provided by
Elastic Beanstalk. You must add AWSEBSecurityGroup to your ElastiCache security
group ingress rules in order for your Elastic Beanstalk application to connect to
the instances in your
ElastiCache cluster.)

The ingress rules for the EC2 security group also define the IP protocol and port
numbers
on which the cache nodes can accept connections. For Redis, the default port number
is
6379.

These lines tell Elastic Beanstalk to get the values for the CacheNodeType,
NumCacheNodes, Engine, and CachePort properties from
the CacheNodeType, NumCacheNodes, Engine, and
CachePort values in a config file (options.config in our
example). That file includes an aws:elasticbeanstalk:customoption section (under
option_settings) that contains name-value pairs with the actual values to use.
In the preceding example, cache.t1.micro, 1, redis, and
6379 would be used for the values. For more information about
Fn::GetOptionSetting, see Functions.

EC2-VPC
(Custom)

If you create a custom VPC on the EC2-VPC platform and specify it as the VPC into
which
EC2 launches instances, the process of adding an Amazon ElastiCache cluster to your
environment differs from that of a default VPC. The main difference is that you must
create a
subnet group for the ElastiCache cluster. All of the properties in this example are
the
minimum required properties that must be set for each resource type.

Note

This example creates AWS resources, which you might be charged for. For more information
about AWS pricing, see
https://aws.amazon.com/pricing/. Some services are part of the AWS Free Usage Tier. If you are a new
customer, you can test drive
these services for free. See https://aws.amazon.com/free/ for more information.

To use this example, do the following:

Create an .ebextensions directory in the top-level directory of your
source bundle.

Create two configuration files with the .config extension and place them
in your .ebextensions directory. One configuration file defines the resources, and the other configuration
file defines the options.

Deploy your application to Elastic Beanstalk.

YAML relies on consistent indentation. Match the indentation level when replacing
content in an example
configuration file and ensure that your text editor uses spaces, not tab characters,
to indent.

Now name the resources configuration file
elasticache.config. To create the ElastiCache cluster, this example
specifies the name of the ElastiCache cluster resource (MyElastiCache), declares
its type, and then configures the properties for the cluster. The properties in the
example
reference the name of the subnet group for the ElastiCache cluster as well as the
ID of
security group resource that we create and define in this configuration file.

Next, we create an EC2 security group. We define the name for this resource, declare
its
type, add a description, the VPC ID, and set the ingress rules for the security group
to allow
access only from instances inside the Elastic Beanstalk security group
(AWSEBSecurityGroup). (The parameter name, AWSEBSecurityGroup, is
a fixed resource name provided by Elastic Beanstalk. You must add
AWSEBSecurityGroup to your ElastiCache security group ingress rules in order
for your Elastic Beanstalk application to connect to the instances in your ElastiCache
cluster.)

The ingress rules for the EC2 security group also define the IP protocol and port
numbers
on which the cache nodes can accept connections. For Redis, the default port number
is
6379. Finally, this example creates a subnet group for the ElastiCache cluster.
We define the name for this resource, declare its type, and add a description and
ID of the
subnet in the subnet group.

These lines tell Elastic Beanstalk to get the values for the CacheNodeType,
NumCacheNodes, Engine, CachePort,
CacheSubnets, and VpcId properties from the
CacheNodeType, NumCacheNodes, Engine,
CachePort, CacheSubnets, and VpcId values in a config
file (options.config in our example). That file includes an
aws:elasticbeanstalk:customoption section (under option_settings)
that contains name-value pairs with sample values. In the example above,
cache.t1.micro, 1, redis, 6379,
subnet-1a1a1a1a, subnet-2b2b2b2b, subnet-3c3c3c3c,
and vpc-4d4d4d4d would be used for the values. For more information about
Fn::GetOptionSetting, see Functions.

Javascript is disabled or is unavailable in your browser.

To use the AWS Documentation, Javascript must be enabled. Please refer to your browser's
Help pages for instructions.