Skip to content

create_cache_security_group

create_cache_security_group(
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    cache_security_group_name: Optional[String] = None,
    description: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateCacheSecurityGroupResult

Creates a new cache security group. Use a cache security group to control access to one or more clusters.

Cache security groups are only used when you are creating a cluster outside of an Amazon Virtual Private Cloud (Amazon VPC). If you are creating a cluster inside of a VPC, use a cache subnet group instead. For more information, see CreateCacheSubnetGroup.

Parameters:

  • cache_security_group_name (Optional[String], default: None ) –

    A name for the cache security group. This value is stored as a lowercase string.

    Constraints: Must contain no more than 255 alphanumeric characters. Cannot be the word "Default".

    Example: mysecuritygroup

  • description (Optional[String], default: None ) –

    A description for the cache security group.

  • tags (Optional[TagList], default: None ) –

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

Raises:

Examples:

CreateCacheSecurityGroup Creates an ElastiCache security group. ElastiCache security groups are only for clusters not running in an AWS VPC.

>>> client.create_cache_security_group(cache_security_group_name='my-cache-sec-grp', description='Example ElastiCache security group.')
Source code in docs_src/capo_elasticache/_services/elasti_cache.py
def create_cache_security_group(
    self,
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    cache_security_group_name: Optional[
        "capo_elasticache.types.string.String"
    ] = None,
    description: Optional["capo_elasticache.types.string.String"] = None,
    tags: Optional["capo_elasticache.types.tag_list.TagList"] = None,
) -> "capo_elasticache.types.create_cache_security_group_result.CreateCacheSecurityGroupResult":
    """<p>Creates a new cache security group. Use a cache security group to control access to one or more clusters.</p> <p>Cache security groups are only used when you are creating a cluster outside of an Amazon Virtual Private Cloud (Amazon VPC). If you are creating a cluster inside of a VPC, use a cache subnet group instead. For more information, see <a href="https://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_CreateCacheSubnetGroup.html">CreateCacheSubnetGroup</a>.</p>

    Args:
        cache_security_group_name: <p>A name for the cache security group. This value is stored as a lowercase string.</p> <p>Constraints: Must contain no more than 255 alphanumeric characters. Cannot be the word "Default".</p> <p>Example: <code>mysecuritygroup</code> </p>
        description: <p>A description for the cache security group.</p>
        tags: <p>A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.</p>

    Raises:
        capo_elasticache.errors.cache_security_group_already_exists_fault.CacheSecurityGroupAlreadyExistsFault: <p>A cache security group with the specified name already exists.</p>
        capo_elasticache.errors.cache_security_group_quota_exceeded_fault.CacheSecurityGroupQuotaExceededFault: <p>The request cannot be processed because it would exceed the allowed number of cache security groups.</p>
        capo_elasticache.errors.invalid_parameter_combination_exception.InvalidParameterCombinationException: <p>Two or more incompatible parameters were specified.</p>
        capo_elasticache.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value for a parameter is invalid.</p>
        capo_elasticache.errors.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would cause the resource to have more than the allowed number of tags. The maximum number of tags permitted on a resource is 50.</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CreateCacheSecurityGroup
        Creates an ElastiCache security group. ElastiCache security groups are only for clusters not running in an AWS VPC.

        >>> client.create_cache_security_group(cache_security_group_name='my-cache-sec-grp', description='Example ElastiCache security group.')
    """

    def _handler(
        req: "OperationRequest[capo_elasticache.types.create_cache_security_group_message.CreateCacheSecurityGroupMessage]",
    ) -> OperationResponse[
        "capo_elasticache.types.create_cache_security_group_result.CreateCacheSecurityGroupResult"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.create_cache_security_group

        output, http_response = (
            capo_elasticache._operations.amazon_elasti_cache_v9.create_cache_security_group.create_cache_security_group(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCacheSecurityGroup")
    )
    input_: capo_elasticache.types.create_cache_security_group_message.CreateCacheSecurityGroupMessage = {}
    if cache_security_group_name is not None:
        input_["cache_security_group_name"] = cache_security_group_name
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output