Skip to content

Commit

Permalink
Merge pull request #207 from JohnPreston/johnpreston/applicationautos…
Browse files Browse the repository at this point in the history
…caling_scheduledaction

ApplicationAutoscaling ScheduledAction Resource
  • Loading branch information
mmaeng authored May 11, 2023
2 parents 1a419fe + f4f8bf6 commit 49b1049
Show file tree
Hide file tree
Showing 16 changed files with 1,225 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resources/ApplicationAutoscaling_ScheduledAction/.rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"artifact_type": "RESOURCE",
"typeName": "AwsCommunity::ApplicationAutoscaling::ScheduledAction",
"language": "python39",
"runtime": "python3.9",
"entrypoint": "awscommunity_applicationautoscaling_scheduledaction.handlers.resource",
"testEntrypoint": "awscommunity_applicationautoscaling_scheduledaction.handlers.test_entrypoint",
"settings": {
"version": false,
"subparser_name": null,
"verbose": 0,
"force": false,
"type_name": null,
"artifact_type": null,
"endpoint_url": null,
"region": null,
"target_schemas": [],
"use_docker": false,
"protocolVersion": "2.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"typeName": "AwsCommunity::ApplicationAutoscaling::ScheduledAction",
"description": "Application Autoscaling Scheduled Action.",
"sourceUrl": "https://github.com/aws-cloudformation/community-registry-extensions",
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"EndTime": {
"type": "string"
},
"ResourceId": {
"type": "string",
"pattern": "[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF\\r\\n\\t]*"
},
"ScalableDimension": {
"type": "string"
},
"ScalableTargetAction": {
"type": "object",
"additionalProperties": false,
"anyOf": [
{
"required": [
"MaxCapacity"
]
},
{
"required": [
"MinCapacity"
]
}
],
"properties": {
"MaxCapacity": {
"type": "number",
"minimum": 0
},
"MinCapacity": {
"type": "number",
"minimum": 0
}
}
},
"Schedule": {
"type": "string",
"pattern": "[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF\\r\\n\\t]*"
},
"ScheduledActionName": {
"type": "string",
"pattern": "(?!((^[ ]+.*)|(.*([\\u0000-\\u001f]|[\\u007f-\\u009f]|[:/|])+.*)|(.*[ ]+$))).+"
},
"ServiceNamespace": {
"type": "string"
},
"StartTime": {
"type": "string"
},
"Timezone": {
"type": "string",
"default": "UTC",
"pattern": "[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF\\r\\n\\t]*"
},
"ScheduledActionARN": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"ScalableDimension",
"ResourceId",
"ScheduledActionName",
"ServiceNamespace",
"Schedule",
"ScalableTargetAction"
],
"readOnlyProperties": [
"/properties/ScheduledActionARN"
],
"primaryIdentifier": [
"/properties/ScheduledActionARN"
],
"createOnlyProperties": [
"/properties/ScheduledActionName",
"/properties/ResourceId",
"/properties/ScalableDimension",
"/properties/ServiceNamespace",
"/properties/ScheduledActionName"
],
"handlers": {
"create": {
"permissions": [
"application-autoscaling:DescribeScheduledActions",
"application-autoscaling:PutScheduledAction"
]
},
"read": {
"permissions": [
"application-autoscaling:DescribeScheduledActions"
]
},
"update": {
"permissions": [
"application-autoscaling:DescribeScheduledActions",
"application-autoscaling:PutScheduledAction"
]
},
"delete": {
"permissions": [
"application-autoscaling:DescribeScheduledActions",
"application-autoscaling:DeleteScheduledAction"
]
}
}
}
149 changes: 149 additions & 0 deletions resources/ApplicationAutoscaling_ScheduledAction/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# AwsCommunity::ApplicationAutoscaling::ScheduledAction

Resource to create a Application Autoscaling Scheduled Action. Can be used with any resource that uses AWS Application Autoscaling Dimensions.

## Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

### JSON

<pre>
{
"Type" : "AwsCommunity::ApplicationAutoscaling::ScheduledAction",
"Properties" : {
"<a href="#endtime" title="EndTime">EndTime</a>" : <i>String</i>,
"<a href="#resourceid" title="ResourceId">ResourceId</a>" : <i>String</i>,
"<a href="#scalabledimension" title="ScalableDimension">ScalableDimension</a>" : <i>String</i>,
"<a href="#scalabletargetaction" title="ScalableTargetAction">ScalableTargetAction</a>" : <i><a href="scalabletargetaction.md">ScalableTargetAction</a></i>,
"<a href="#schedule" title="Schedule">Schedule</a>" : <i>String</i>,
"<a href="#scheduledactionname" title="ScheduledActionName">ScheduledActionName</a>" : <i>String</i>,
"<a href="#servicenamespace" title="ServiceNamespace">ServiceNamespace</a>" : <i>String</i>,
"<a href="#starttime" title="StartTime">StartTime</a>" : <i>String</i>,
"<a href="#timezone" title="Timezone">Timezone</a>" : <i>String</i>,
}
}
</pre>

### YAML

<pre>
Type: AwsCommunity::ApplicationAutoscaling::ScheduledAction
Properties:
<a href="#endtime" title="EndTime">EndTime</a>: <i>String</i>
<a href="#resourceid" title="ResourceId">ResourceId</a>: <i>String</i>
<a href="#scalabledimension" title="ScalableDimension">ScalableDimension</a>: <i>String</i>
<a href="#scalabletargetaction" title="ScalableTargetAction">ScalableTargetAction</a>: <i><a href="scalabletargetaction.md">ScalableTargetAction</a></i>
<a href="#schedule" title="Schedule">Schedule</a>: <i>String</i>
<a href="#scheduledactionname" title="ScheduledActionName">ScheduledActionName</a>: <i>String</i>
<a href="#servicenamespace" title="ServiceNamespace">ServiceNamespace</a>: <i>String</i>
<a href="#starttime" title="StartTime">StartTime</a>: <i>String</i>
<a href="#timezone" title="Timezone">Timezone</a>: <i>String</i>
</pre>

## Properties

#### EndTime

_Required_: No

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### ResourceId

Must be a valid resource as defined in https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScheduledAction.html#autoscaling-PutScheduledAction-request-ResourceId

_Required_: Yes

_Type_: String

_Pattern_: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>

_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

#### ScalableDimension

_Required_: Yes

_Type_: String

_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

#### ScalableTargetAction

_Required_: Yes

_Type_: <a href="scalabletargetaction.md">ScalableTargetAction</a>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### Schedule

Must be a valid schedule as defined in https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScheduledAction.html#autoscaling-PutScheduledAction-request-ResourceId

_Required_: Yes

_Type_: String

_Pattern_: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### ScheduledActionName

Must be a valid action name as defined in https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScheduledAction.html#autoscaling-PutScheduledAction-request-ResourceId

_Required_: Yes

_Type_: String

_Pattern_: <code>(?!((^[ ]+.*)|(.*([\u0000-\u001f]|[\u007f-\u009f]|[:/|])+.*)|(.*[ ]+$))).+</code>

_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

#### ServiceNamespace

_Required_: Yes

_Type_: String

_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

#### StartTime

_Required_: No

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### Timezone

Must be a valid timestamp as defined in https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScheduledAction.html#autoscaling-PutScheduledAction-request-ResourceId

_Required_: No

_Type_: String

_Pattern_: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return Values

### Ref

When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the ScheduledActionARN.

### Fn::GetAtt

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html).

#### ScheduledActionARN

Returns the <code>ScheduledActionARN</code> value.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AwsCommunity::ApplicationAutoscaling::ScheduledAction ScalableTargetAction

## Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

### JSON

<pre>
{
"<a href="#maxcapacity" title="MaxCapacity">MaxCapacity</a>" : <i>Double</i>,
"<a href="#mincapacity" title="MinCapacity">MinCapacity</a>" : <i>Double</i>
}
</pre>

### YAML

<pre>
<a href="#maxcapacity" title="MaxCapacity">MaxCapacity</a>: <i>Double</i>
<a href="#mincapacity" title="MinCapacity">MinCapacity</a>: <i>Double</i>
</pre>

## Properties

#### MaxCapacity

_Required_: Yes

_Type_: Double

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### MinCapacity

_Required_: Yes

_Type_: Double

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ScheduledActionName": "cfn-testing-resource",
"ServiceNamespace": "dynamodb",
"ScalableDimension": "dynamodb:table:ReadCapacityUnits",
"ScalableTargetAction": {
"MinCapacity": 1,
"MaxCapacity": 4
},
"Schedule": "cron(5 2 ? * FRI)",
"Timezone": "Europe/London",
"ResourceId": "table/awscommunityscheduledactiontesttable"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ScheduledActionName": "cfn-testing-resource",
"ServiceNamespace": "dynamodb",
"ScalableDimension": "dynamodb:table:ReadCapacityUnits",
"ScalableTargetAction": {
"MinCapacity": 1,
"MaxCapacity": 4
},
"Schedule": "cron(5 2 ? * FRI)",
"Timezone": "Europe/London",
"ResourceId": "table/awscommunityscheduledactiontesttable-does-not-exist"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ScheduledActionName": "cfn-testing-resource",
"ServiceNamespace": "dynamodb",
"ScalableDimension": "dynamodb:table:ReadCapacityUnits",
"ScalableTargetAction": {
"MinCapacity": 1,
"MaxCapacity": 1
},
"Schedule": "cron(10 2 ? * FRI)",
"Timezone": "Europe/London",
"ResourceId": "table/awscommunityscheduledactiontesttable"
}
14 changes: 14 additions & 0 deletions resources/ApplicationAutoscaling_ScheduledAction/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
attrs==23.1.0 ; python_version >= "3.8" and python_version < "4.0"
aws-encryption-sdk==3.1.1 ; python_version >= "3.8" and python_version < "4.0"
boto3==1.26.131 ; python_version >= "3.8" and python_version < "4.0"
botocore==1.29.131 ; python_version >= "3.8" and python_version < "4.0"
cffi==1.15.1 ; python_version >= "3.8" and python_version < "4.0"
cloudformation-cli-python-lib==2.1.16 ; python_version >= "3.8" and python_version < "4.0"
cryptography==40.0.2 ; python_version >= "3.8" and python_version < "4.0"
jmespath==1.0.1 ; python_version >= "3.8" and python_version < "4.0"
pycparser==2.21 ; python_version >= "3.8" and python_version < "4.0"
python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "4.0"
s3transfer==0.6.1 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
urllib3==1.26.15 ; python_version >= "3.8" and python_version < "4.0"
wrapt==1.15.0 ; python_version >= "3.8" and python_version < "4.0"
Loading

0 comments on commit 49b1049

Please sign in to comment.