-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Serverless Application Repository initial support #15874
Conversation
…e function; will be reused for Update
…te function; will be reused for Update
…o separate function; will be reused for Update" This was a premature simplification
This confirms that no tags show up in the state when no tags are added to the resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of changes, I think overall this is handling this unique service pretty well though 👍
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resource import support is missing acceptance testing, e.g.
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
@@ -0,0 +1,50 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is missing section on resource import.
getApplicationInput := &serverlessrepository.GetApplicationInput{ | ||
ApplicationId: aws.String(d.Get("application_id").(string)), | ||
} | ||
|
||
_, ok := d.GetOk("semantic_version") | ||
if !ok { | ||
getApplicationOutput, err := serverlessConn.GetApplication(getApplicationInput) | ||
if err != nil { | ||
return err | ||
} | ||
d.Set("semantic_version", getApplicationOutput.Version.SemanticVersion) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely cause issues on import since it is currently set to ImportStatePassthrough
-- will need to add these to custom import function where they are present in the ID then passed into the correct attributes for the Read
function.
return nil | ||
} | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help operators and code maintainers with context around error messages:
return err | |
return fmt.Errorf("error describing CloudFormation Stack (%s): %w", d.Id(), err) |
See also: #15892
Deploys an application from the Serverless Application Repository. | ||
--- | ||
|
||
# Resource: aws_serverlessrepository_application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Resource: aws_serverlessrepository_application | |
# Resource: aws_serverlessrepository_stack |
(Or whatever is decided with potentially lengthening the naming)
See also: #15842
|
||
# Resource: aws_serverlessrepository_application | ||
|
||
Deploys an application from the Serverless Application Repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploys an application from the Serverless Application Repository. | |
Deploys a CloudFormation Stack using an Application from the Serverless Application Repository. |
## Example Usage | ||
|
||
```hcl | ||
resource "aws_serverlessrepository_application" "postgres-rotator" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or whatever is decided with potentially lengthening the naming)
resource "aws_serverlessrepository_application" "postgres-rotator" { | |
resource "aws_serverlessrepository_stack" "postgres-rotator" { |
aws/provider.go
Outdated
@@ -892,6 +893,7 @@ func Provider() *schema.Provider { | |||
"aws_securityhub_member": resourceAwsSecurityHubMember(), | |||
"aws_securityhub_product_subscription": resourceAwsSecurityHubProductSubscription(), | |||
"aws_securityhub_standards_subscription": resourceAwsSecurityHubStandardsSubscription(), | |||
"aws_serverlessrepository_stack": resourceAwsServerlessRepositoryStack(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize if we've discussed this before, but these SAR resources and data sources should probably be expanded to the full service naming per the Contribution Guide, unless there is a blocking reason not to (length be darned 🙁 ).
"aws_serverlessapplicationrepository_stack": resourceAwsServerlessApplicationRepositoryStack(),
We may also want to consider adding "CloudFormation" Stack in here to match the API CreateCloudFormationStack naming, in case SAR releases some other form of "stacks" (such as its own).
"aws_serverlessapplicationrepository_cloudformation_stack": resourceAwsServerlessApplicationRepositoryCloudFormationStack(),
var e *resource.NotFoundError | ||
if errors.As(err, &e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since its not being used yet (only tfresource.TimedOut
), it might be good time to update
terraform-provider-aws/aws/internal/tfresource/errors.go
Lines 9 to 12 in 2975c11
func NotFound(err error) bool { | |
_, ok := err.(*resource.NotFoundError) | |
return ok | |
} |
errors.As
and use it here. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! 🚀
Output from acceptance testing in AWS Commercial:
--- PASS: TestAccDataSourceAwsServerlessApplicationRepositoryApplication_Basic (52.09s)
--- PASS: TestAccDataSourceAwsServerlessApplicationRepositoryApplication_Versioned (92.29s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_disappears (138.27s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_paired (142.73s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_basic (164.41s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_update (232.10s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_versioned (262.14s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_Tags (271.30s)
Output from acceptance testing in AWS GovCloud (US):
--- PASS: TestAccDataSourceAwsServerlessApplicationRepositoryApplication_Basic (86.85s)
--- PASS: TestAccDataSourceAwsServerlessApplicationRepositoryApplication_Versioned (97.04s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_disappears (129.86s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_basic (143.42s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_paired (144.45s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_update (226.49s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_Tags (250.56s)
--- PASS: TestAccAwsServerlessApplicationRepositoryCloudFormationStack_versioned (257.11s)
_, ok := err.(*resource.NotFoundError) | ||
return ok | ||
var e *resource.NotFoundError | ||
return errors.As(err, &e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
This has been released in version 3.18.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Adds AWS Serverless Application Repository applications to the Terraform provider. Replaces #5961, since I'm no longer working with that fork of the provider repo.
Community Note
Closes #3981
Release note for CHANGELOG:
Output from acceptance testing: