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

r/synthetics_canary - new resource #13140

Merged
merged 67 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
2981497
add canary
DrFaust92 May 3, 2020
155fef5
add canary to provider.go
DrFaust92 May 3, 2020
7dce1f6
fix conn for update
DrFaust92 May 3, 2020
c8d4c1d
add update logic
DrFaust92 May 3, 2020
6a820b8
add support for zip file + mutex
DrFaust92 May 3, 2020
40696f0
add some initial tests
DrFaust92 May 3, 2020
bb65dff
suppress diff for `artifact_s3_location`
DrFaust92 May 4, 2020
7d73537
fix suppress diff + conflict
DrFaust92 May 4, 2020
f6feeaf
flatten code block, similar to AWS lambda
DrFaust92 May 4, 2020
c00fe9e
tests passing
DrFaust92 May 4, 2020
6804ce6
add waiter for canary
DrFaust92 May 4, 2020
87045b3
add waiter for update
DrFaust92 May 4, 2020
b118240
fix arn and tagging
DrFaust92 May 4, 2020
ebf1a06
add `source_location_arn`
DrFaust92 May 4, 2020
67d04c9
add disappears test
DrFaust92 Jul 18, 2020
4b5deb9
add docs
DrFaust92 Jul 18, 2020
b5e73e5
fill code part of docs
DrFaust92 Jul 18, 2020
5040381
add lambda deletion logic for in vpc tests
DrFaust92 Jul 18, 2020
014915b
waiter + run config changes
DrFaust92 Jul 18, 2020
0ae32c0
fix setting `memory_in_mb`
DrFaust92 Jul 18, 2020
29c205b
add docs regarding implicit resources
DrFaust92 Jul 18, 2020
e83ba39
add docs regarding permissions needed for role
DrFaust92 Jul 18, 2020
4a17a24
fix name of file
DrFaust92 Jul 18, 2020
e9d40a4
delete vpc config gracefully
DrFaust92 Jul 19, 2020
1291728
use v2
DrFaust92 Aug 13, 2020
e4f111a
tf12 syntax test
DrFaust92 Aug 14, 2020
a5f0d7c
typo
DrFaust92 Aug 14, 2020
d085db9
nit for arn var name
DrFaust92 Aug 27, 2020
364da77
add checks for lambda, lambda layer, role and s3 location
DrFaust92 Aug 27, 2020
293642a
simplify s3 code artifact + test
DrFaust92 Aug 27, 2020
09d31b5
gnarly implicit lambda handling
DrFaust92 Aug 27, 2020
38bf316
lint
DrFaust92 Sep 19, 2020
67680f2
lint
DrFaust92 Sep 19, 2020
1e3ae2d
start canary docs
DrFaust92 Sep 19, 2020
e26a674
start/stop canary
DrFaust92 Sep 19, 2020
96c546f
added `timeline` check for update with local code
DrFaust92 Sep 21, 2020
f2df362
added timeline docs
DrFaust92 Sep 21, 2020
f4f2af7
start test more, check for start
DrFaust92 Sep 21, 2020
6248a2f
add sweeper + also deletes implict resources
DrFaust92 Sep 21, 2020
6a03cad
remove non existent sweeper
DrFaust92 Sep 21, 2020
b2e6cc6
allow changing runtime version
DrFaust92 Oct 3, 2020
063120e
set runtime version in tests
DrFaust92 Oct 3, 2020
470ce43
runtime versiom docs
DrFaust92 Oct 3, 2020
2ec3a70
runtime version fix+ test
DrFaust92 Oct 3, 2020
4f94a2f
active tracing
DrFaust92 Oct 3, 2020
cf0446c
add tracing test
DrFaust92 Oct 3, 2020
9ccd3c9
tracing docs
DrFaust92 Oct 3, 2020
23b10f5
lint
DrFaust92 Oct 3, 2020
341a85d
lint
DrFaust92 Oct 3, 2020
bc309ff
Apply suggestions from code review
DrFaust92 Oct 29, 2020
aff1052
Update aws/resource_aws_synthetics_canary.go
DrFaust92 Nov 17, 2020
ac61561
add more validation for names
DrFaust92 Nov 17, 2020
a1f7694
fix lint
DrFaust92 Nov 17, 2020
cc23b08
use finder
DrFaust92 Nov 17, 2020
7e7414b
fix
DrFaust92 Nov 18, 2020
a48ad23
ignore s3 arguments
DrFaust92 Nov 18, 2020
1b43d1b
env vars
DrFaust92 Nov 19, 2020
c357b30
revert env var
DrFaust92 Jan 16, 2021
ae3e310
resource/synthetics_canary: Use finder in waiter status
YakDriver Feb 12, 2021
5dfe396
docs/synthetics_canary: Minor changes to docs
YakDriver Feb 12, 2021
4881bb6
resource/synthetics_canary: Sort arguments
YakDriver Feb 12, 2021
0da88b5
resource/synthetics_canary: Minor fixes
YakDriver Feb 12, 2021
2a53c48
resource/synthetics_canary: Sort config block args
YakDriver Feb 12, 2021
93badf3
tests/resource/synthetics_canary: Fix deprecated versions
YakDriver Feb 12, 2021
2bf734a
tests/resource/sythentics_canary: Use composeConfig()
YakDriver Feb 12, 2021
617a9c2
resource/synthetics_canary: Changelog
YakDriver Feb 12, 2021
6568886
docs/synthetics_canary: Update runtime versions
YakDriver Feb 12, 2021
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
3 changes: 3 additions & 0 deletions .changelog/13140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_synthetics_canary
```
20 changes: 20 additions & 0 deletions aws/internal/service/synthetics/finder/finder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package finder

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/synthetics"
)

// CanaryByName returns the Canary corresponding to the specified Name.
func CanaryByName(conn *synthetics.Synthetics, name string) (*synthetics.GetCanaryOutput, error) {
input := &synthetics.GetCanaryInput{
Name: aws.String(name),
}

output, err := conn.GetCanary(input)
if err != nil {
return nil, err
}

return output, nil
}
26 changes: 26 additions & 0 deletions aws/internal/service/synthetics/waiter/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package waiter

import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/synthetics"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/synthetics/finder"
)

func CanaryStatus(conn *synthetics.Synthetics, name string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := finder.CanaryByName(conn, name)

if err != nil {
return nil, synthetics.CanaryStateError, err
}

if aws.StringValue(output.Canary.Status.State) == synthetics.CanaryStateError {
return output, synthetics.CanaryStateError, fmt.Errorf("%s: %s", aws.StringValue(output.Canary.Status.StateReasonCode), aws.StringValue(output.Canary.Status.StateReason))
}

return output, aws.StringValue(output.Canary.Status.State), nil
}
}
90 changes: 90 additions & 0 deletions aws/internal/service/synthetics/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package waiter

import (
"time"

"github.com/aws/aws-sdk-go/service/synthetics"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
// Maximum amount of time to wait for a Canary to return Ready
CanaryCreatedTimeout = 5 * time.Minute
CanaryRunningTimeout = 5 * time.Minute
CanaryStoppedTimeout = 5 * time.Minute
CanaryDeletedTimeout = 5 * time.Minute
)

// CanaryReady waits for a Canary to return Ready
func CanaryReady(conn *synthetics.Synthetics, name string) (*synthetics.GetCanaryOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{synthetics.CanaryStateCreating, synthetics.CanaryStateUpdating},
Target: []string{synthetics.CanaryStateReady},
Refresh: CanaryStatus(conn, name),
Timeout: CanaryCreatedTimeout,
}

outputRaw, err := stateConf.WaitForState()

if v, ok := outputRaw.(*synthetics.GetCanaryOutput); ok {
return v, err
}

return nil, err
}

// CanaryReady waits for a Canary to return Stopped
func CanaryStopped(conn *synthetics.Synthetics, name string) (*synthetics.GetCanaryOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{synthetics.CanaryStateStopping, synthetics.CanaryStateUpdating,
synthetics.CanaryStateRunning, synthetics.CanaryStateReady, synthetics.CanaryStateStarting},
Target: []string{synthetics.CanaryStateStopped},
Refresh: CanaryStatus(conn, name),
Timeout: CanaryStoppedTimeout,
}

outputRaw, err := stateConf.WaitForState()

if v, ok := outputRaw.(*synthetics.GetCanaryOutput); ok {
return v, err
}

return nil, err
}

// CanaryReady waits for a Canary to return Running
func CanaryRunning(conn *synthetics.Synthetics, name string) (*synthetics.GetCanaryOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{synthetics.CanaryStateStarting, synthetics.CanaryStateUpdating,
synthetics.CanaryStateStarting, synthetics.CanaryStateReady},
Target: []string{synthetics.CanaryStateRunning},
Refresh: CanaryStatus(conn, name),
Timeout: CanaryRunningTimeout,
}

outputRaw, err := stateConf.WaitForState()

if v, ok := outputRaw.(*synthetics.GetCanaryOutput); ok {
return v, err
}

return nil, err
}

// CanaryReady waits for a Canary to return Ready
func CanaryDeleted(conn *synthetics.Synthetics, name string) (*synthetics.GetCanaryOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{synthetics.CanaryStateDeleting, synthetics.CanaryStateStopped},
Target: []string{},
Refresh: CanaryStatus(conn, name),
Timeout: CanaryDeletedTimeout,
}

outputRaw, err := stateConf.WaitForState()

if v, ok := outputRaw.(*synthetics.GetCanaryOutput); ok {
return v, err
}

return nil, err
}
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ func Provider() *schema.Provider {
"aws_default_subnet": resourceAwsDefaultSubnet(),
"aws_subnet": resourceAwsSubnet(),
"aws_swf_domain": resourceAwsSwfDomain(),
"aws_synthetics_canary": resourceAwsSyntheticsCanary(),
"aws_transfer_server": resourceAwsTransferServer(),
"aws_transfer_ssh_key": resourceAwsTransferSshKey(),
"aws_transfer_user": resourceAwsTransferUser(),
Expand Down
Loading