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

Rename reference to **AWS CloudFormation** in the resource schema #1784

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

wellsiau-aws
Copy link
Collaborator

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Relates OR Closes #1783

This new function will run after schemas is downloaded and will check for any reference to AWS CloudFormation within the schema.

@wellsiau-aws
Copy link
Collaborator Author

Example output

diff --git a/internal/aws/s3/bucket_resource_gen.go b/internal/aws/s3/bucket_resource_gen.go
index 99015cb97..691999fea 100644
--- a/internal/aws/s3/bucket_resource_gen.go
+++ b/internal/aws/s3/bucket_resource_gen.go
@@ -483,11 +483,11 @@ func bucketResource(ctx context.Context) (resource.Resource, error) {
                // CloudFormation resource type schema:
                //
                //      {
-               //        "description": "A name for the bucket. If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow [Amazon S3 bucket restrictions and limitations](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html). For more information, see [Rules for naming Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules) in the *Amazon S3 User Guide*. \n  If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.",
+               //        "description": "A name for the bucket. If you don't specify a name, Terraform generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow [Amazon S3 bucket restrictions and limitations](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html). For more information, see [Rules for naming Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules) in the *Amazon S3 User Guide*. \n  If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.",
                //        "type": "string"
                //      }
                "bucket_name": schema.StringAttribute{ /*START ATTRIBUTE*/
-                       Description: "A name for the bucket. If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow [Amazon S3 bucket restrictions and limitations](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html). For more information, see [Rules for naming Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules) in the *Amazon S3 User Guide*. \n  If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.",
+                       Description: "A name for the bucket. If you don't specify a name, Terraform generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow [Amazon S3 bucket restrictions and limitations](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html). For more information, see [Rules for naming Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules) in the *Amazon S3 User Guide*. \n  If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.",
                        Optional:    true,
                        Computed:    true,
                        PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
@@ -3011,7 +3011,7 @@ func bucketResource(ctx context.Context) (resource.Resource, error) {
                //                  "type": "object"
                //                },
                //                "Id": {
-               //                  "description": "A unique identifier for the rule. The maximum value is 255 characters. If you don't specify a value, AWS CloudFormation generates a random ID. When using a V2 replication configuration this property is capitalized as \"ID\".",
+               //                  "description": "A unique identifier for the rule. The maximum value is 255 characters. If you don't specify a value, Terraform generates a random ID. When using a V2 replication configuration this property is capitalized as \"ID\".",
                //                  "maxLength": 255,
                //                  "type": "string"
                //                },
@@ -3364,7 +3364,7 @@ func bucketResource(ctx context.Context) (resource.Resource, error) {
                                                        }, /*END ATTRIBUTE*/
                                                        // Property: Id
                                                        "id": schema.StringAttribute{ /*START ATTRIBUTE*/
-                                                               Description: "A unique identifier for the rule. The maximum value is 255 characters. If you don't specify a value, AWS CloudFormation generates a random ID. When using a V2 replication configuration this property is capitalized as \"ID\".",
+                                                               Description: "A unique identifier for the rule. The maximum value is 255 characters. If you don't specify a value, Terraform generates a random ID. When using a V2 replication configuration this property is capitalized as \"ID\".",
                                                                Optional:    true,
                                                                Computed:    true,
                                                                Validators: []validator.String{ /*START VALIDATORS*/
@@ -3875,7 +3875,7 @@ func bucketResource(ctx context.Context) (resource.Resource, error) {
        }
 
        schema := schema.Schema{
-               Description: "The ``AWS::S3::Bucket`` resource creates an Amazon S3 bucket in the same AWS Region where you create the AWS CloudFormation stack.\n To control how AWS CloudFormation handles the bucket when the stack is deleted, you can set a deletion policy for your bucket. You can choose to *retain* the buck
et or to *delete* the bucket. For more information, see [DeletionPolicy Attribute](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html).\n  You can only delete empty buckets. Deletion fails for buckets that have contents.",
+               Description: "The ``AWS::S3::Bucket`` resource creates an Amazon S3 bucket in the same AWS Region where you create the Terraform stack.\n To control how Terraform handles the bucket when the stack is deleted, you can set a deletion policy for your bucket. You can choose to *retain* the bucket or to *delete* 
the bucket. For more information, see [DeletionPolicy Attribute](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html).\n  You can only delete empty buckets. Deletion fails for buckets that have contents.",
                Version:     1,
                Attributes:  attributes,
        }

@breathingdust
Copy link
Member

Hi @wellsiau-aws 👋 ,

Something like this was my first thought as well, however I don’t think it will do the right thing on all occasions. So if we do move forward with this approach we would need to be comfortable with those tradeoffs. The usage of CloudFormation in the documentation occurs in a number of different contexts in which replacing it with Terraform can be correct, incorrect or even confusing.

There are also a few permutations of CloudFormation to consider, CloudFormation, AWS CloudFormation, CloudFormation Stack as well as the abbreviated CFN are all found in the documentation.

Below are a non-exhaustive set of examples of what effects this approach might have where the output is non-ideal, there are about 109 mentions of CloudFormation (excluding CloudFormation Resources) in the documentation:

awscc_applicationautoscaling_scalable_target

Custom resources are not supported with a resource type. This parameter must specify the ``OutputValue`` from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our [GitHub repository](https://docs.aws.amazon.com/https://github.com/aws/aws-auto-scaling-custom-resource).

This would be renamed to “Terraform Template Stack” and be potentially misleading. Generally the “stack” verbiage is problematic, although it may make sense in some occasions.

awscc_appsync_function_configuration

- `response_mapping_template_s3_location` (String) The location of a response mapping template in an Amazon S3 bucket. Use this if you want to provision with a template file in Amazon S3 rather than embedding it in your CloudFormation template.

I think this is correct in intent, but the term template doesn’t map well with Terraform terminology.

awscc_autoscaling_auto_scaling_group

 For help migrating from launch configurations to launch templates, see Migrate CloudFormation stacks from launch configurations to launch templates https://docs.aws.amazon.com/autoscaling/ec2/userguide/migrate-launch-configurations-with-cloudformation.html in the Amazon EC2 Auto Scaling User Guide.

It's fine to link to CloudFormation documentation for more information, however this would rename would suggest a Terraform guide rather than a CloudFormation one.

awscc_cloudtrail_resource_policy

- `resource_policy` (String) A policy document containing permissions to add to the specified resource. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM.

I would assume that using YAML would work correctly for this resource policy, however the rename would not be entirely correct.

awscc_codestarconnections_sync_configuration

- `role_arn` (String) The IAM Role that allows AWS to update CloudFormation stacks based on content in the specified repository.

Correct, however we probably don’t want to use the term stacks.

awscc_ec2_vpc_endpoint

  • policy_document (String) An endpoint policy, which controls access to the service from the VPC. The default endpoint policy allows full access to the service. Endpoint policies are supported only for gateway and interface endpoints.
    For CloudFormation templates in YAML, you can provide the policy in JSON or YAML format. CFNlong converts YAML policies to JSON format before calling the API to create or modify the VPC endpoint.

Not correct to convert.

awscc_gamelift_fleet

Note: It is not currently possible to use the !Ref command to reference a script created with a CloudFormation template for the fleet property ScriptId. Instead, use Fn::GetAtt Script.Arn or Fn::GetAtt Script.Id to retrieve either of these properties as input for ScriptId. Alternatively, enter a ScriptId string manually.

Mentions of CloudFormation specific functions

awscc_grafana_workspace

- `stack_set_name` (String) The name of the AWS CloudFormation stack set to use to generate IAM roles to be used for this workspace.

In this case the attribute is specifically a CloudFormation references and should not be renamed.

awscc_kms_alias

 KMS CloudFormation resources are available in all AWS-Regions in which KMS and CFN are supported.

Mention of CFN

@wellsiau-aws
Copy link
Collaborator Author

@breathingdust , yes, that is the same concern I had as I started to explore this option.

if we are committed to explore this path, I think we could modify the rename.go function to use LLM (i.e. Bedrock) to get context of the text and offer replacement only when its applicable. This would require AWS creds available during the GitHub workflow, which might be a no-go.

The best solution obviously is to have this addressed by the upstream Cfn schema in form of keyword replacement vs literal mention of CloudFormation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove reference to AWS CloudFormation in the resource documentation
4 participants