test: aws_appautoscaling_scheduled_action resource
parent
cf2ef1c968
commit
4a04648371
|
@ -159,6 +159,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
|
|||
{name: "network acl rule", dirName: "aws_network_acl_rule", wantErr: false},
|
||||
{name: "default network acl", dirName: "aws_default_network_acl", wantErr: false},
|
||||
{name: "App autoscaling policy", dirName: "aws_appautoscaling_policy", wantErr: false},
|
||||
{name: "App autoscaling scheduled action", dirName: "aws_appautoscaling_scheduled_action", wantErr: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
{
|
||||
"Id": "dynamodb-dynamodb-table/GameScores",
|
||||
"Type": "aws_appautoscaling_scheduled_action",
|
||||
"Attrs": {
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:scheduledAction:cf26c451-97f8-49f9-9cdd-515135e7d0f3:resource/dynamodb/table/GameScores:scheduledActionName/dynamodb",
|
||||
"id": "dynamodb-dynamodb-table/GameScores",
|
||||
"name": "dynamodb",
|
||||
"resource_id": "table/GameScores",
|
||||
"scalable_dimension": "dynamodb:table:ReadCapacityUnits",
|
||||
"scalable_target_action": [
|
||||
{
|
||||
"max_capacity": 200,
|
||||
"min_capacity": 1
|
||||
}
|
||||
],
|
||||
"schedule": "at(2006-01-02T15:04:05)",
|
||||
"service_namespace": "dynamodb"
|
||||
}
|
||||
}
|
||||
]
|
171757
pkg/iac/terraform/state/test/aws_appautoscaling_scheduled_action/schema.golden.json
Executable file
171757
pkg/iac/terraform/state/test/aws_appautoscaling_scheduled_action/schema.golden.json
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,74 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_dynamodb_table" "basic-dynamodb-table" {
|
||||
name = "GameScores"
|
||||
billing_mode = "PROVISIONED"
|
||||
read_capacity = 20
|
||||
write_capacity = 20
|
||||
hash_key = "UserId"
|
||||
range_key = "GameTitle"
|
||||
|
||||
attribute {
|
||||
name = "UserId"
|
||||
type = "S"
|
||||
}
|
||||
|
||||
attribute {
|
||||
name = "GameTitle"
|
||||
type = "S"
|
||||
}
|
||||
|
||||
attribute {
|
||||
name = "TopScore"
|
||||
type = "N"
|
||||
}
|
||||
|
||||
ttl {
|
||||
attribute_name = "TimeToExist"
|
||||
enabled = false
|
||||
}
|
||||
|
||||
global_secondary_index {
|
||||
name = "GameTitleIndex"
|
||||
hash_key = "GameTitle"
|
||||
range_key = "TopScore"
|
||||
write_capacity = 10
|
||||
read_capacity = 10
|
||||
projection_type = "INCLUDE"
|
||||
non_key_attributes = ["UserId"]
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "dynamodb-table-1"
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_appautoscaling_target" "dynamodb" {
|
||||
max_capacity = 100
|
||||
min_capacity = 5
|
||||
resource_id = "table/${aws_dynamodb_table.basic-dynamodb-table.name}"
|
||||
scalable_dimension = "dynamodb:table:ReadCapacityUnits"
|
||||
service_namespace = "dynamodb"
|
||||
}
|
||||
|
||||
resource "aws_appautoscaling_scheduled_action" "dynamodb" {
|
||||
name = "dynamodb"
|
||||
service_namespace = aws_appautoscaling_target.dynamodb.service_namespace
|
||||
resource_id = aws_appautoscaling_target.dynamodb.resource_id
|
||||
scalable_dimension = aws_appautoscaling_target.dynamodb.scalable_dimension
|
||||
schedule = "at(2006-01-02T15:04:05)"
|
||||
|
||||
scalable_target_action {
|
||||
min_capacity = 1
|
||||
max_capacity = 200
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.15.5",
|
||||
"serial": 5,
|
||||
"lineage": "811d29d8-62df-ee46-fd20-1519cb3a1cb6",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_appautoscaling_scheduled_action",
|
||||
"name": "dynamodb",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:scheduledAction:cf26c451-97f8-49f9-9cdd-515135e7d0f3:resource/dynamodb/table/GameScores:scheduledActionName/dynamodb",
|
||||
"end_time": null,
|
||||
"id": "dynamodb-dynamodb-table/GameScores",
|
||||
"name": "dynamodb",
|
||||
"resource_id": "table/GameScores",
|
||||
"scalable_dimension": "dynamodb:table:ReadCapacityUnits",
|
||||
"scalable_target_action": [
|
||||
{
|
||||
"max_capacity": 200,
|
||||
"min_capacity": 1
|
||||
}
|
||||
],
|
||||
"schedule": "at(2006-01-02T15:04:05)",
|
||||
"service_namespace": "dynamodb",
|
||||
"start_time": null
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA==",
|
||||
"dependencies": [
|
||||
"aws_appautoscaling_target.dynamodb",
|
||||
"aws_dynamodb_table.basic-dynamodb-table"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package aws_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cloudskiff/driftctl/test"
|
||||
"github.com/cloudskiff/driftctl/test/acceptance"
|
||||
)
|
||||
|
||||
func TestAcc_Aws_AppAutoscalingScheduledAction(t *testing.T) {
|
||||
acceptance.Run(t, acceptance.AccTestCase{
|
||||
TerraformVersion: "0.15.5",
|
||||
Paths: []string{"./testdata/acc/aws_appautoscaling_scheduled_action"},
|
||||
Args: []string{"scan", "--filter", "Type=='aws_appautoscaling_scheduled_action'"},
|
||||
Checks: []acceptance.AccCheck{
|
||||
{
|
||||
Env: map[string]string{
|
||||
"AWS_REGION": "us-east-1",
|
||||
},
|
||||
Check: func(result *test.ScanResult, stdout string, err error) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result.AssertInfrastructureIsInSync()
|
||||
result.AssertManagedCount(1)
|
||||
result.AssertDriftCountTotal(0)
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
20
pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl
vendored
Normal file
20
pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/aws" {
|
||||
version = "3.19.0"
|
||||
constraints = "3.19.0"
|
||||
hashes = [
|
||||
"h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=",
|
||||
"zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b",
|
||||
"zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c",
|
||||
"zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd",
|
||||
"zh:770855565462abadbbddd98cb357d2f1a8f30f68a358cb37cbd5c072cb15b377",
|
||||
"zh:8008db43149fe4345301f81e15e6d9ddb47aa5e7a31648f9b290af96ad86e92a",
|
||||
"zh:8cdd27d375da6dcb7687f1fed126b7c04efce1671066802ee876dbbc9c66ec79",
|
||||
"zh:be22ae185005690d1a017c1b909e0d80ab567e239b4f06ecacdba85080667c1c",
|
||||
"zh:d2d02e72dbd80f607636cd6237a6c862897caabc635c7b50c0cb243d11246723",
|
||||
"zh:d8f125b66a1eda2555c0f9bbdf12036a5f8d073499a22ca9e4812b68067fea31",
|
||||
"zh:f5a98024c64d5d2973ff15b093725a074c0cb4afde07ef32c542e69f17ac90bc",
|
||||
]
|
||||
}
|
74
pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/terraform.tf
vendored
Normal file
74
pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/terraform.tf
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_dynamodb_table" "basic-dynamodb-table" {
|
||||
name = "GameScores"
|
||||
billing_mode = "PROVISIONED"
|
||||
read_capacity = 20
|
||||
write_capacity = 20
|
||||
hash_key = "UserId"
|
||||
range_key = "GameTitle"
|
||||
|
||||
attribute {
|
||||
name = "UserId"
|
||||
type = "S"
|
||||
}
|
||||
|
||||
attribute {
|
||||
name = "GameTitle"
|
||||
type = "S"
|
||||
}
|
||||
|
||||
attribute {
|
||||
name = "TopScore"
|
||||
type = "N"
|
||||
}
|
||||
|
||||
ttl {
|
||||
attribute_name = "TimeToExist"
|
||||
enabled = false
|
||||
}
|
||||
|
||||
global_secondary_index {
|
||||
name = "GameTitleIndex"
|
||||
hash_key = "GameTitle"
|
||||
range_key = "TopScore"
|
||||
write_capacity = 10
|
||||
read_capacity = 10
|
||||
projection_type = "INCLUDE"
|
||||
non_key_attributes = ["UserId"]
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "dynamodb-table-1"
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_appautoscaling_target" "dynamodb" {
|
||||
max_capacity = 100
|
||||
min_capacity = 5
|
||||
resource_id = "table/${aws_dynamodb_table.basic-dynamodb-table.name}"
|
||||
scalable_dimension = "dynamodb:table:ReadCapacityUnits"
|
||||
service_namespace = "dynamodb"
|
||||
}
|
||||
|
||||
resource "aws_appautoscaling_scheduled_action" "dynamodb" {
|
||||
name = "dynamodb"
|
||||
service_namespace = aws_appautoscaling_target.dynamodb.service_namespace
|
||||
resource_id = aws_appautoscaling_target.dynamodb.resource_id
|
||||
scalable_dimension = aws_appautoscaling_target.dynamodb.scalable_dimension
|
||||
schedule = "at(2006-01-02T15:04:05)"
|
||||
|
||||
scalable_target_action {
|
||||
min_capacity = 1
|
||||
max_capacity = 200
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue