mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Cleanups on Kinesis naming
This commit is contained in:
parent
214ed23974
commit
9a1ae44475
@ -55,9 +55,6 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// set name as ID for now. Kinesis stream names are unique per account+region
|
|
||||||
d.SetId(sn)
|
|
||||||
|
|
||||||
stateConf := &resource.StateChangeConf{
|
stateConf := &resource.StateChangeConf{
|
||||||
Pending: []string{"CREATING"},
|
Pending: []string{"CREATING"},
|
||||||
Target: "ACTIVE",
|
Target: "ACTIVE",
|
||||||
@ -75,7 +72,8 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := streamRaw.(*kinesis.StreamDescription)
|
s := streamRaw.(*kinesis.StreamDescription)
|
||||||
d.Set("arn", *s.StreamARN)
|
d.SetId(*s.StreamARN)
|
||||||
|
d.Set("arn", s.StreamARN)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -83,7 +81,7 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er
|
|||||||
func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).kinesisconn
|
conn := meta.(*AWSClient).kinesisconn
|
||||||
describeOpts := &kinesis.DescribeStreamInput{
|
describeOpts := &kinesis.DescribeStreamInput{
|
||||||
StreamName: aws.String(d.Id()),
|
StreamName: aws.String(d.Get("name").(string)),
|
||||||
Limit: aws.Long(1),
|
Limit: aws.Long(1),
|
||||||
}
|
}
|
||||||
resp, err := conn.DescribeStream(describeOpts)
|
resp, err := conn.DescribeStream(describeOpts)
|
||||||
@ -107,8 +105,9 @@ func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) erro
|
|||||||
|
|
||||||
func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).kinesisconn
|
conn := meta.(*AWSClient).kinesisconn
|
||||||
|
sn := d.Get("name").(string)
|
||||||
_, err := conn.DeleteStream(&kinesis.DeleteStreamInput{
|
_, err := conn.DeleteStream(&kinesis.DeleteStreamInput{
|
||||||
StreamName: aws.String(d.Id()),
|
StreamName: aws.String(sn),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -118,7 +117,7 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er
|
|||||||
stateConf := &resource.StateChangeConf{
|
stateConf := &resource.StateChangeConf{
|
||||||
Pending: []string{"DELETING"},
|
Pending: []string{"DELETING"},
|
||||||
Target: "DESTROYED",
|
Target: "DESTROYED",
|
||||||
Refresh: streamStateRefreshFunc(conn, d.Id()),
|
Refresh: streamStateRefreshFunc(conn, sn),
|
||||||
Timeout: 5 * time.Minute,
|
Timeout: 5 * time.Minute,
|
||||||
Delay: 10 * time.Second,
|
Delay: 10 * time.Second,
|
||||||
MinTimeout: 3 * time.Second,
|
MinTimeout: 3 * time.Second,
|
||||||
@ -128,17 +127,17 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Error waiting for Stream (%s) to be destroyed: %s",
|
"Error waiting for Stream (%s) to be destroyed: %s",
|
||||||
d.Id(), err)
|
sn, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func streamStateRefreshFunc(conn *kinesis.Kinesis, streamName string) resource.StateRefreshFunc {
|
func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefreshFunc {
|
||||||
return func() (interface{}, string, error) {
|
return func() (interface{}, string, error) {
|
||||||
describeOpts := &kinesis.DescribeStreamInput{
|
describeOpts := &kinesis.DescribeStreamInput{
|
||||||
StreamName: aws.String(streamName),
|
StreamName: aws.String(sn),
|
||||||
Limit: aws.Long(1),
|
Limit: aws.Long(1),
|
||||||
}
|
}
|
||||||
resp, err := conn.DescribeStream(describeOpts)
|
resp, err := conn.DescribeStream(describeOpts)
|
||||||
|
@ -45,7 +45,7 @@ func testAccCheckKinesisStreamExists(n string, stream *kinesis.StreamDescription
|
|||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).kinesisconn
|
conn := testAccProvider.Meta().(*AWSClient).kinesisconn
|
||||||
describeOpts := &kinesis.DescribeStreamInput{
|
describeOpts := &kinesis.DescribeStreamInput{
|
||||||
StreamName: aws.String(rs.Primary.ID),
|
StreamName: aws.String(rs.Primary.Attributes["name"]),
|
||||||
Limit: aws.Long(1),
|
Limit: aws.Long(1),
|
||||||
}
|
}
|
||||||
resp, err := conn.DescribeStream(describeOpts)
|
resp, err := conn.DescribeStream(describeOpts)
|
||||||
@ -83,7 +83,7 @@ func testAccCheckKinesisStreamDestroy(s *terraform.State) error {
|
|||||||
}
|
}
|
||||||
conn := testAccProvider.Meta().(*AWSClient).kinesisconn
|
conn := testAccProvider.Meta().(*AWSClient).kinesisconn
|
||||||
describeOpts := &kinesis.DescribeStreamInput{
|
describeOpts := &kinesis.DescribeStreamInput{
|
||||||
StreamName: aws.String(rs.Primary.ID),
|
StreamName: aws.String(rs.Primary.Attributes["name"]),
|
||||||
Limit: aws.Long(1),
|
Limit: aws.Long(1),
|
||||||
}
|
}
|
||||||
resp, err := conn.DescribeStream(describeOpts)
|
resp, err := conn.DescribeStream(describeOpts)
|
||||||
|
Loading…
Reference in New Issue
Block a user