feat: add aws_appautoscaling_policy resource
parent
b3619e36d0
commit
317eb5c779
|
@ -157,6 +157,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
|
|||
{name: "network acl", dirName: "aws_network_acl", wantErr: false},
|
||||
{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},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
[
|
||||
{
|
||||
"Id": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"Type": "aws_appautoscaling_policy",
|
||||
"Attrs": {
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:scalingPolicy:081dd219-093d-4a1d-8207-423db1d49bd9:resource/dynamodb/table/GameScores:policyName/DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"id": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"name": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"policy_type": "TargetTrackingScaling",
|
||||
"resource_id": "table/GameScores",
|
||||
"scalable_dimension": "dynamodb:table:ReadCapacityUnits",
|
||||
"service_namespace": "dynamodb",
|
||||
"target_tracking_scaling_policy_configuration": [
|
||||
{
|
||||
"disable_scale_in": false,
|
||||
"predefined_metric_specification": [
|
||||
{
|
||||
"predefined_metric_type": "DynamoDBReadCapacityUtilization",
|
||||
"resource_label": ""
|
||||
}
|
||||
],
|
||||
"scale_in_cooldown": 0,
|
||||
"scale_out_cooldown": 0,
|
||||
"target_value": 70
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
|||
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_table_read_target" {
|
||||
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_policy" "dynamodb_table_read_policy" {
|
||||
name = "DynamoDBReadCapacityUtilization:${aws_appautoscaling_target.dynamodb_table_read_target.resource_id}"
|
||||
policy_type = "TargetTrackingScaling"
|
||||
resource_id = aws_appautoscaling_target.dynamodb_table_read_target.resource_id
|
||||
scalable_dimension = aws_appautoscaling_target.dynamodb_table_read_target.scalable_dimension
|
||||
service_namespace = aws_appautoscaling_target.dynamodb_table_read_target.service_namespace
|
||||
|
||||
target_tracking_scaling_policy_configuration {
|
||||
predefined_metric_specification {
|
||||
predefined_metric_type = "DynamoDBReadCapacityUtilization"
|
||||
}
|
||||
|
||||
target_value = 70
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.15.5",
|
||||
"serial": 5,
|
||||
"lineage": "c8768afb-27a7-733f-87cc-40b93f0dbfe9",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_appautoscaling_policy",
|
||||
"name": "dynamodb_table_read_policy",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:scalingPolicy:081dd219-093d-4a1d-8207-423db1d49bd9:resource/dynamodb/table/GameScores:policyName/DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"id": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"name": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"policy_type": "TargetTrackingScaling",
|
||||
"resource_id": "table/GameScores",
|
||||
"scalable_dimension": "dynamodb:table:ReadCapacityUnits",
|
||||
"service_namespace": "dynamodb",
|
||||
"step_scaling_policy_configuration": [],
|
||||
"target_tracking_scaling_policy_configuration": [
|
||||
{
|
||||
"customized_metric_specification": [],
|
||||
"disable_scale_in": false,
|
||||
"predefined_metric_specification": [
|
||||
{
|
||||
"predefined_metric_type": "DynamoDBReadCapacityUtilization",
|
||||
"resource_label": ""
|
||||
}
|
||||
],
|
||||
"scale_in_cooldown": 0,
|
||||
"scale_out_cooldown": 0,
|
||||
"target_value": 70
|
||||
}
|
||||
]
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA==",
|
||||
"dependencies": [
|
||||
"aws_appautoscaling_target.dynamodb_table_read_target",
|
||||
"aws_dynamodb_table.basic-dynamodb-table"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -129,3 +129,106 @@ func TestAppAutoScalingTarget(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppAutoScalingPolicy(t *testing.T) {
|
||||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "should return one policy",
|
||||
dirName: "aws_appautoscaling_policy_single",
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalingPolicies", "dynamodb").Return([]*applicationautoscaling.ScalingPolicy{
|
||||
{
|
||||
PolicyName: awssdk.String("DynamoDBReadCapacityUtilization:table/GameScores"),
|
||||
ResourceId: awssdk.String("table/GameScores"),
|
||||
ScalableDimension: awssdk.String("dynamodb:table:ReadCapacityUnits"),
|
||||
ServiceNamespace: awssdk.String("dynamodb"),
|
||||
},
|
||||
}, nil).Once()
|
||||
|
||||
client.On("DescribeScalingPolicies", mock.AnythingOfType("string")).Return([]*applicationautoscaling.ScalingPolicy{}, nil).Times(len(applicationautoscaling.ServiceNamespace_Values()) - 1)
|
||||
},
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
test: "should return remote error",
|
||||
dirName: "aws_appautoscaling_policy_single",
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalingPolicies", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once()
|
||||
},
|
||||
wantErr: remoteerror.NewResourceListingError(errors.New("remote error"), resourceaws.AwsAppAutoscalingPolicyResourceType),
|
||||
},
|
||||
}
|
||||
|
||||
schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0")
|
||||
resourceaws.InitResourcesMetadata(schemaRepository)
|
||||
factory := terraform.NewTerraformResourceFactory(schemaRepository)
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
|
||||
for _, c := range tests {
|
||||
t.Run(c.test, func(tt *testing.T) {
|
||||
shouldUpdate := c.dirName == *goldenfile.Update
|
||||
|
||||
sess := session.Must(session.NewSessionWithOptions(session.Options{
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
}))
|
||||
|
||||
scanOptions := ScannerOptions{Deep: true}
|
||||
providerLibrary := terraform.NewProviderLibrary()
|
||||
remoteLibrary := common.NewRemoteLibrary()
|
||||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository.MockAppAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository.AppAutoScalingRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider := terraform2.NewFakeTerraformProvider(realProvider)
|
||||
provider.WithResponse(c.dirName)
|
||||
|
||||
// Replace mock by real resources if we are in update mode
|
||||
if shouldUpdate {
|
||||
err := realProvider.Init()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository.NewAppAutoScalingRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewAppAutoscalingPolicyEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
||||
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||
got, err := s.Resources()
|
||||
if err != nil {
|
||||
assert.EqualError(tt, c.wantErr, err.Error())
|
||||
} else {
|
||||
assert.Equal(tt, err, c.wantErr)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
test.TestAgainstGoldenFile(got, resourceaws.AwsAppAutoscalingPolicyResourceType, c.dirName, provider, deserializer, shouldUpdate, tt)
|
||||
alerter.AssertExpectations(tt)
|
||||
fakeRepo.AssertExpectations(tt)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
)
|
||||
|
||||
type AppAutoscalingPolicyEnumerator struct {
|
||||
repository repository.AppAutoScalingRepository
|
||||
factory resource.ResourceFactory
|
||||
}
|
||||
|
||||
func NewAppAutoscalingPolicyEnumerator(repository repository.AppAutoScalingRepository, factory resource.ResourceFactory) *AppAutoscalingPolicyEnumerator {
|
||||
return &AppAutoscalingPolicyEnumerator{
|
||||
repository,
|
||||
factory,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *AppAutoscalingPolicyEnumerator) SupportedType() resource.ResourceType {
|
||||
return aws.AwsAppAutoscalingPolicyResourceType
|
||||
}
|
||||
|
||||
func (e *AppAutoscalingPolicyEnumerator) Enumerate() ([]*resource.Resource, error) {
|
||||
policies := make([]*applicationautoscaling.ScalingPolicy, 0)
|
||||
|
||||
for _, ns := range e.repository.ServiceNamespaceValues() {
|
||||
results, err := e.repository.DescribeScalingPolicies(ns)
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
|
||||
}
|
||||
policies = append(policies, results...)
|
||||
}
|
||||
|
||||
results := make([]*resource.Resource, 0)
|
||||
|
||||
for _, policy := range policies {
|
||||
results = append(
|
||||
results,
|
||||
e.factory.CreateAbstractResource(
|
||||
string(e.SupportedType()),
|
||||
*policy.PolicyName,
|
||||
map[string]interface{}{
|
||||
"name": *policy.PolicyName,
|
||||
"resource_id": *policy.ResourceId,
|
||||
"scalable_dimension": *policy.ScalableDimension,
|
||||
"service_namespace": *policy.ServiceNamespace,
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
|
@ -190,6 +190,9 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddEnumerator(NewAppAutoscalingTargetEnumerator(appAutoScalingRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewAppAutoscalingPolicyEnumerator(appAutoScalingRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, provider, deserializer))
|
||||
|
||||
err = resourceSchemaRepository.Init(terraform.AWS, provider.Version(), provider.Schema())
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
type AppAutoScalingRepository interface {
|
||||
ServiceNamespaceValues() []string
|
||||
DescribeScalableTargets(string) ([]*applicationautoscaling.ScalableTarget, error)
|
||||
DescribeScalingPolicies(string) ([]*applicationautoscaling.ScalingPolicy, error)
|
||||
}
|
||||
|
||||
type appAutoScalingRepository struct {
|
||||
|
@ -47,3 +48,21 @@ func (r *appAutoScalingRepository) DescribeScalableTargets(namespace string) ([]
|
|||
r.cache.Put(cacheKey, result.ScalableTargets)
|
||||
return result.ScalableTargets, nil
|
||||
}
|
||||
|
||||
func (r *appAutoScalingRepository) DescribeScalingPolicies(namespace string) ([]*applicationautoscaling.ScalingPolicy, error) {
|
||||
cacheKey := fmt.Sprintf("appAutoScalingDescribeScalingPolicies_%s", namespace)
|
||||
if v := r.cache.Get(cacheKey); v != nil {
|
||||
return v.([]*applicationautoscaling.ScalingPolicy), nil
|
||||
}
|
||||
|
||||
input := &applicationautoscaling.DescribeScalingPoliciesInput{
|
||||
ServiceNamespace: &namespace,
|
||||
}
|
||||
result, err := r.client.DescribeScalingPolicies(input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.cache.Put(cacheKey, result.ScalingPolicies)
|
||||
return result.ScalingPolicies, nil
|
||||
}
|
||||
|
|
|
@ -122,3 +122,112 @@ func Test_appautoscalingRepository_DescribeScalableTargets(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_appautoscalingRepository_DescribeScalingPolicies(t *testing.T) {
|
||||
type args struct {
|
||||
namespace string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
mocks func(*awstest.MockFakeApplicationAutoScaling, *cache.MockCache)
|
||||
want []*applicationautoscaling.ScalingPolicy
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "should return remote error",
|
||||
args: args{
|
||||
namespace: "test",
|
||||
},
|
||||
mocks: func(client *awstest.MockFakeApplicationAutoScaling, c *cache.MockCache) {
|
||||
client.On("DescribeScalingPolicies",
|
||||
&applicationautoscaling.DescribeScalingPoliciesInput{
|
||||
ServiceNamespace: aws.String("test"),
|
||||
}).Return(nil, errors.New("remote error")).Once()
|
||||
|
||||
c.On("Get", "appAutoScalingDescribeScalingPolicies_test").Return(nil).Once()
|
||||
},
|
||||
want: nil,
|
||||
wantErr: errors.New("remote error"),
|
||||
},
|
||||
{
|
||||
name: "should return scaling policies",
|
||||
args: args{
|
||||
namespace: "test",
|
||||
},
|
||||
mocks: func(client *awstest.MockFakeApplicationAutoScaling, c *cache.MockCache) {
|
||||
results := []*applicationautoscaling.ScalingPolicy{
|
||||
{
|
||||
PolicyARN: aws.String("test_policy"),
|
||||
},
|
||||
}
|
||||
|
||||
client.On("DescribeScalingPolicies",
|
||||
&applicationautoscaling.DescribeScalingPoliciesInput{
|
||||
ServiceNamespace: aws.String("test"),
|
||||
}).Return(&applicationautoscaling.DescribeScalingPoliciesOutput{
|
||||
ScalingPolicies: results,
|
||||
}, nil).Once()
|
||||
|
||||
c.On("Get", "appAutoScalingDescribeScalingPolicies_test").Return(nil).Once()
|
||||
c.On("Put", "appAutoScalingDescribeScalingPolicies_test", results).Return(true).Once()
|
||||
},
|
||||
want: []*applicationautoscaling.ScalingPolicy{
|
||||
{
|
||||
PolicyARN: aws.String("test_policy"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "should hit cache return scaling policies",
|
||||
args: args{
|
||||
namespace: "test",
|
||||
},
|
||||
mocks: func(client *awstest.MockFakeApplicationAutoScaling, c *cache.MockCache) {
|
||||
results := []*applicationautoscaling.ScalingPolicy{
|
||||
{
|
||||
PolicyARN: aws.String("test_policy"),
|
||||
},
|
||||
}
|
||||
|
||||
c.On("Get", "appAutoScalingDescribeScalingPolicies_test").Return(results).Once()
|
||||
},
|
||||
want: []*applicationautoscaling.ScalingPolicy{
|
||||
{
|
||||
PolicyARN: aws.String("test_policy"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
store := &cache.MockCache{}
|
||||
client := &awstest.MockFakeApplicationAutoScaling{}
|
||||
tt.mocks(client, store)
|
||||
|
||||
r := &appAutoScalingRepository{
|
||||
client: client,
|
||||
cache: store,
|
||||
}
|
||||
got, err := r.DescribeScalingPolicies(tt.args.namespace)
|
||||
if err != nil {
|
||||
assert.EqualError(t, tt.wantErr, err.Error())
|
||||
} else {
|
||||
assert.Equal(t, tt.wantErr, err)
|
||||
}
|
||||
|
||||
changelog, err := diff.Diff(got, tt.want)
|
||||
assert.Nil(t, err)
|
||||
if len(changelog) > 0 {
|
||||
for _, change := range changelog {
|
||||
t.Errorf("%s: %s -> %s", strings.Join(change.Path, "."), change.From, change.To)
|
||||
}
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
client.AssertExpectations(t)
|
||||
store.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,29 @@ func (_m *MockAppAutoScalingRepository) DescribeScalableTargets(_a0 string) ([]*
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// DescribeScalingPolicies provides a mock function with given fields: _a0
|
||||
func (_m *MockAppAutoScalingRepository) DescribeScalingPolicies(_a0 string) ([]*applicationautoscaling.ScalingPolicy, error) {
|
||||
ret := _m.Called(_a0)
|
||||
|
||||
var r0 []*applicationautoscaling.ScalingPolicy
|
||||
if rf, ok := ret.Get(0).(func(string) []*applicationautoscaling.ScalingPolicy); ok {
|
||||
r0 = rf(_a0)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*applicationautoscaling.ScalingPolicy)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(_a0)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ServiceNamespaceValues provides a mock function with given fields:
|
||||
func (_m *MockAppAutoScalingRepository) ServiceNamespaceValues() []string {
|
||||
ret := _m.Called()
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"Typ": "WyJvYmplY3QiLHsiYXJuIjoic3RyaW5nIiwiaWQiOiJzdHJpbmciLCJuYW1lIjoic3RyaW5nIiwicG9saWN5X3R5cGUiOiJzdHJpbmciLCJyZXNvdXJjZV9pZCI6InN0cmluZyIsInNjYWxhYmxlX2RpbWVuc2lvbiI6InN0cmluZyIsInNlcnZpY2VfbmFtZXNwYWNlIjoic3RyaW5nIiwic3RlcF9zY2FsaW5nX3Bv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Err": null
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
[
|
||||
{
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:scalingPolicy:012b61a9-c500-41a0-84a4-019976bd10fc:resource/dynamodb/table/GameScores:policyName/DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"id": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"name": "DynamoDBReadCapacityUtilization:table/GameScores",
|
||||
"policy_type": "TargetTrackingScaling",
|
||||
"resource_id": "table/GameScores",
|
||||
"scalable_dimension": "dynamodb:table:ReadCapacityUnits",
|
||||
"service_namespace": "dynamodb",
|
||||
"step_scaling_policy_configuration": null,
|
||||
"target_tracking_scaling_policy_configuration": [
|
||||
{
|
||||
"customized_metric_specification": null,
|
||||
"disable_scale_in": false,
|
||||
"predefined_metric_specification": [
|
||||
{
|
||||
"predefined_metric_type": "DynamoDBReadCapacityUtilization",
|
||||
"resource_label": ""
|
||||
}
|
||||
],
|
||||
"scale_in_cooldown": 0,
|
||||
"scale_out_cooldown": 0,
|
||||
"target_value": 70
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy"
|
||||
|
||||
func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"name": *res.Attributes().GetString("name"),
|
||||
"resource_id": *res.Attributes().GetString("resource_id"),
|
||||
"service_namespace": *res.Attributes().GetString("service_namespace"),
|
||||
"scalable_dimension": *res.Attributes().GetString("scalable_dimension"),
|
||||
}
|
||||
})
|
||||
}
|
|
@ -61,4 +61,5 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsCloudformationStackMetaData(resourceSchemaRepository)
|
||||
initAwsVpcMetaData(resourceSchemaRepository)
|
||||
initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository)
|
||||
initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository)
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ var supportedTypes = map[string]struct{}{
|
|||
"aws_api_gateway_authorizer": {},
|
||||
"aws_appautoscaling_target": {},
|
||||
"aws_rds_cluster_instance": {},
|
||||
"aws_appautoscaling_policy": {},
|
||||
|
||||
"github_branch_protection": {},
|
||||
"github_membership": {},
|
||||
|
|
Loading…
Reference in New Issue