Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws_redshift_scheduled_action resource #13474

Merged
merged 27 commits into from
Sep 29, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add create method excepted target_action
  • Loading branch information
hitofuji authored and ewbankkit committed Sep 28, 2021
commit dc6c8c126958e05715e94a357b8438db6418017a
32 changes: 31 additions & 1 deletion aws/resource_aws_redshift_scheduled_action.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package aws

import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/glue"
"github.com/aws/aws-sdk-go/service/redshift"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"time"
)

func resourceAwsRedshiftScheduledAction() *schema.Resource {
@@ -31,7 +35,6 @@ func resourceAwsRedshiftScheduledAction() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"active": {
Type: schema.TypeBool,
@@ -93,5 +96,32 @@ func resourceAwsRedshiftScheduledAction() *schema.Resource {
},
},
}
}

func resourceAwsRedshiftScheduledActionCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).redshiftconn
var name string
if v, ok := d.GetOk("name"); ok {
name = v.(string)
} else {
name = resource.UniqueId()
}
createOpts := &redshift.CreateScheduledActionInput{
ScheduledActionName: aws.String(name),
Schedule: aws.String(d.Get("schedule").(string)),
IamRole: aws.String(d.Get("iam_role").(string)),
}
// TODO: add target_action
if attr, ok := d.GetOk("description"); ok {
createOpts.ScheduledActionDescription = aws.String(attr.(string))
}
if attr, ok := d.GetOk("active"); ok {
createOpts.Enable = aws.Bool(attr.(bool))
}
if attr, ok := d.GetOk("start_time"); ok {
createOpts.StartTime = aws.Time(attr.(time.Time))
}
if attr, ok := d.GetOk("end_time"); ok {
createOpts.EndTime = aws.Time(attr.(time.Time))
}
}