diff --git a/changelog.md b/changelog.md
index 934e484..982ff3b 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
+## [Unreleased]
+
+### Added
+
+- Default attributes for metadata.
+
## [0.10.0] - 2024/07/11
### Added
diff --git a/src/assets/metadata/aws/compute.js b/src/assets/metadata/aws/compute.js
index 4989ae7..fa3e543 100644
--- a/src/assets/metadata/aws/compute.js
+++ b/src/assets/metadata/aws/compute.js
@@ -1,3 +1,5 @@
+import { securityGroups, subnetId } from 'src/assets/metadata/aws/default';
+
const awsInstance = {
type: 'aws_instance',
blockType: 'resource',
@@ -11,14 +13,8 @@ const awsInstance = {
tags: [],
definedAttributes: [
{
- name: 'security_groups',
- displayName: 'Security groups',
- description: 'List of security group names to associate with.',
- linkAttribute: 'name',
- linkRef: 'aws_security_group',
+ ...securityGroups,
linkType: 'Reverse',
- linkModel: 'defaultLink',
- type: 'Link',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#security_groups',
},
{
@@ -33,14 +29,8 @@ const awsInstance = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#vpc_security_group_ids',
},
{
- name: 'subnet_id',
- displayName: 'Subnet ID',
+ ...subnetId,
description: 'The VPC Subnet ID to launch in.',
- linkAttribute: 'id',
- linkRef: 'aws_subnet',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#subnet_id',
},
],
@@ -120,13 +110,7 @@ const awsLaunchConfiguration = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_configuration.html#name_prefix',
},
{
- name: 'security_groups',
- displayName: 'Security groups',
- description: 'A list of associated security group IDS.',
- linkRef: 'aws_security_group',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
+ ...securityGroups,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_configuration.html#security_groups',
},
{
diff --git a/src/assets/metadata/aws/databases.js b/src/assets/metadata/aws/databases.js
index c8fa3d1..c04805c 100644
--- a/src/assets/metadata/aws/databases.js
+++ b/src/assets/metadata/aws/databases.js
@@ -1,3 +1,5 @@
+import { port, tags } from 'src/assets/metadata/aws/default';
+
const awsDbInstance = {
type: 'aws_db_instance',
blockType: 'resource',
@@ -290,15 +292,9 @@ const awsDbInstance = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#performance_insights_retention_period',
},
{
- name: 'port',
- displayName: 'Port',
+ ...port,
description: 'The port on which the DB accepts connections.',
- type: 'Number',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#port',
- rules: {
- max: '65535',
- min: '1',
- },
},
{
name: 'replica_mode',
@@ -458,10 +454,7 @@ const awsDbInstance = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#customer_owned_ip_enabled',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A mapping of tags to assign to the DB instance.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#tags',
},
],
diff --git a/src/assets/metadata/aws/default.js b/src/assets/metadata/aws/default.js
new file mode 100644
index 0000000..47a33ae
--- /dev/null
+++ b/src/assets/metadata/aws/default.js
@@ -0,0 +1,63 @@
+export const vpcIdLink = {
+ name: 'vpc_id',
+ displayName: 'VPC ID',
+ containerRef: 'aws_vpc',
+ linkAttribute: 'id',
+ linkRef: 'aws_vpc',
+ linkType: 'Default',
+ linkModel: 'defaultLink',
+ type: 'Link',
+};
+
+export const vpcIdReference = {
+ name: 'vpc_id',
+ displayName: 'VPC ID',
+ containerRef: 'aws_vpc',
+ type: 'Reference',
+};
+
+export const tags = {
+ name: 'tags',
+ displayName: 'Tags',
+ description: 'A map of tags to assign to the resource.',
+ type: 'Object',
+ url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
+};
+
+export const securityGroups = {
+ name: 'security_groups',
+ displayName: 'Security groups',
+ description: 'List of security group names to associate with.',
+ linkAttribute: 'name',
+ linkRef: 'aws_security_group',
+ linkType: 'Default',
+ linkModel: 'defaultLink',
+ type: 'Link',
+};
+
+export const subnetId = {
+ name: 'subnet_id',
+ displayName: 'Subnet ID',
+ linkAttribute: 'id',
+ linkRef: 'aws_subnet',
+ linkType: 'Default',
+ linkModel: 'defaultLink',
+ type: 'Link',
+};
+
+export const port = {
+ name: 'port',
+ displayName: 'Port',
+ type: 'Number',
+ rules: {
+ max: '65535',
+ min: '1',
+ },
+};
+
+export const ipv6Address = {
+ name: 'ipv6_address',
+ displayName: 'IPv6 address',
+ description: 'The IPv6 address.',
+ type: 'String',
+};
diff --git a/src/assets/metadata/aws/loadbalancing.js b/src/assets/metadata/aws/loadbalancing.js
index a626edd..0381cba 100644
--- a/src/assets/metadata/aws/loadbalancing.js
+++ b/src/assets/metadata/aws/loadbalancing.js
@@ -1,3 +1,12 @@
+import {
+ ipv6Address,
+ port,
+ securityGroups, subnetId,
+ tags,
+ vpcIdLink,
+ vpcIdReference,
+} from 'src/assets/metadata/aws/default';
+
const awsElb = {
type: 'aws_elb',
blockType: 'resource',
@@ -64,14 +73,7 @@ const awsElb = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elb#subnets',
},
{
- name: 'security_groups',
- displayName: 'Security groups',
- description: 'A list of security group IDs to assign to the ELB.',
- linkAttribute: 'id',
- linkRef: 'aws_security_group',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
+ ...securityGroups,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elb#security_groups',
},
{
@@ -101,11 +103,8 @@ const awsLb = {
tags: [],
definedAttributes: [
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdReference,
description: 'The ID of the VPC to create the ALB in.',
- containerRef: 'aws_vpc',
- type: 'Reference',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#vpc_id',
},
{
@@ -249,13 +248,7 @@ const awsLb = {
},
},
{
- name: 'security_groups',
- displayName: 'Security groups',
- description: 'A list of security group IDs to assign to the LB. Only valid for Load Balancers of type application.',
- linkRef: 'aws_security_group',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
+ ...securityGroups,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#security_groups',
},
{
@@ -273,10 +266,8 @@ const awsLb = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#subnet_mapping',
definedAttributes: [
{
- name: 'subnet_id',
- displayName: 'Subnet ID',
+ ...subnetId,
description: 'ID of the subnet of which to attach to the load balancer. You can specify only one subnet per Availability Zone.',
- type: 'String',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#subnet_id',
},
{
@@ -287,10 +278,8 @@ const awsLb = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#allocation_id',
},
{
- name: 'ipv6_address',
- displayName: 'IPv6 address',
+ ...ipv6Address,
description: 'The IPv6 address. You associate IPv6 CIDR blocks with your VPC and choose the subnets
where you launch both internet-facing and internal Application Load Balancers or Network Load Balancers.',
- type: 'String',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#ipv6_address',
},
{
@@ -320,10 +309,7 @@ const awsLb = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#name_prefix',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource. If configured with a provider default_tags configuration block present,
tags with matching keys will overwrite those defined at the provider-level.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#tags',
},
],
@@ -390,10 +376,8 @@ const awsLbTargetGroup = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#name_prefix',
},
{
- name: 'port',
- displayName: 'Port',
+ ...port,
description: 'Port on which targets receive traffic, unless overridden when registering a specific target.',
- type: 'Number',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#port',
},
{
@@ -463,13 +447,8 @@ const awsLbTargetGroup = {
},
},
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdLink,
description: 'Identifier of the VPC in which to create the target group.',
- linkRef: 'aws_vpc',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#vpc_id',
},
{
@@ -515,10 +494,8 @@ const awsLbTargetGroup = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#path',
},
{
- name: 'port',
- displayName: 'Port',
+ ...port,
description: 'The port the load balancer uses when performing health checks on targets.',
- type: 'Number',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#port',
},
{
@@ -597,13 +574,7 @@ const awsLbTargetGroup = {
},
],
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
- url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
- },
+ tags,
{
name: 'target_failover',
displayName: 'Target failover',
@@ -704,21 +675,15 @@ const awsLbListener = {
},
{
name: 'certificate_arn',
- displayName: 'Cerificate ARN',
+ displayName: 'Certificate ARN',
description: 'ARN of the default SSL server certificate.',
type: 'String',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#certificate_arn',
},
{
- name: 'port',
- displayName: 'Port',
+ ...port,
description: 'Port on which the load balancer is listening.',
- type: 'Number',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#port',
- rules: {
- max: 65535,
- min: 1,
- },
},
{
name: 'protocol',
@@ -761,10 +726,7 @@ const awsLbListener = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#ssl_policy',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A mapping of tags to assign to the resource.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#tags',
},
],
diff --git a/src/assets/metadata/aws/networking.js b/src/assets/metadata/aws/networking.js
index 7044226..2bac138 100644
--- a/src/assets/metadata/aws/networking.js
+++ b/src/assets/metadata/aws/networking.js
@@ -1,3 +1,5 @@
+import { subnetId, tags, vpcIdReference } from 'src/assets/metadata/aws/default';
+
const awsVpc = {
type: 'aws_vpc',
blockType: 'resource',
@@ -130,13 +132,7 @@ const awsVpc = {
type: 'Boolean',
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/network-address-usage.html',
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
- url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
- },
+ tags,
],
};
@@ -153,12 +149,9 @@ const awsSubnet = {
tags: [],
definedAttributes: [
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdReference,
description: 'The VPC ID to create the subnet in.',
- containerRef: 'aws_vpc',
required: true,
- type: 'Reference',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#vpc_id',
},
{
@@ -274,10 +267,7 @@ const awsSubnet = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#outpost_arn',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#tags',
},
],
@@ -357,12 +347,9 @@ const awsRouteTable = {
tags: [],
definedAttributes: [
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdReference,
description: 'The ID of the VPC for which to create the route table.',
- containerRef: 'aws_vpc',
required: true,
- type: 'Reference',
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html',
},
{
@@ -372,13 +359,7 @@ const awsRouteTable = {
type: 'Array',
url: 'https://docs.aws.amazon.com/directconnect/latest/UserGuide/virtualgateways.html',
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
- url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
- },
+ tags,
],
};
@@ -395,11 +376,8 @@ const awsRouteTableAssociation = {
tags: [],
definedAttributes: [
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdReference,
description: 'The ID of the VPC for which to create the route table association.',
- containerRef: 'aws_vpc',
- type: 'Reference',
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html',
},
{
@@ -424,13 +402,8 @@ const awsRouteTableAssociation = {
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html',
},
{
- name: 'subnet_id',
- displayName: 'Subnet ID',
+ ...subnetId,
description: 'The ID of the subnet to associate the route table with. Conflicts with gateway_id.',
- linkRef: 'aws_subnet',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html',
},
],
@@ -449,20 +422,11 @@ const awsInternetGateway = {
tags: [],
definedAttributes: [
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdReference,
description: 'The VPC ID to create the gateway in.',
- containerRef: 'aws_vpc',
- type: 'Reference',
url: 'https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html',
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
- url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
- },
+ tags,
],
};
diff --git a/src/assets/metadata/aws/provider.js b/src/assets/metadata/aws/provider.js
index f1e3865..b2bf71e 100644
--- a/src/assets/metadata/aws/provider.js
+++ b/src/assets/metadata/aws/provider.js
@@ -1,3 +1,5 @@
+import { tags } from 'src/assets/metadata/aws/default';
+
export default [{
blockType: 'provider',
type: 'aws',
@@ -237,13 +239,7 @@ export default [{
type: 'String',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs#source_identity',
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'Map of assume role session tags.',
- type: 'Array',
- url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs#tags',
- },
+ tags,
{
name: 'transitive_tag_keys',
displayName: 'Transitive tag keys',
@@ -319,13 +315,7 @@ export default [{
type: 'Object',
url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
definedAttributes: [
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'Key-value map of tags to apply to all resources.',
- type: 'Object',
- url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs#tags',
- },
+ tags,
],
},
{
diff --git a/src/assets/metadata/aws/security.js b/src/assets/metadata/aws/security.js
index af01293..1d6225e 100644
--- a/src/assets/metadata/aws/security.js
+++ b/src/assets/metadata/aws/security.js
@@ -1,3 +1,5 @@
+import { tags, vpcIdLink } from 'src/assets/metadata/aws/default';
+
const awsSecurityGroup = {
type: 'aws_security_group',
blockType: 'resource',
@@ -39,15 +41,8 @@ const awsSecurityGroup = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group#revoke_rules_on_delete',
},
{
- name: 'vpc_id',
- displayName: 'VPC ID',
+ ...vpcIdLink,
description: 'The ID of the VPC for which to create the security group.',
- containerRef: 'aws_vpc',
- linkAttribute: 'id',
- linkRef: 'aws_vpc',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group#vpc_id',
},
{
@@ -144,13 +139,7 @@ const awsSecurityGroup = {
},
],
},
- {
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
- url: 'https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html',
- },
+ tags,
],
};
@@ -189,10 +178,7 @@ const awsKeyPair = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair#key_name_prefix',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A mapping of tags to assign to the resource.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair#tags',
},
],
diff --git a/src/assets/metadata/aws/storage.js b/src/assets/metadata/aws/storage.js
index ebe001a..2ddebed 100644
--- a/src/assets/metadata/aws/storage.js
+++ b/src/assets/metadata/aws/storage.js
@@ -1,3 +1,5 @@
+import { securityGroups, subnetId, tags } from 'src/assets/metadata/aws/default';
+
const awsEbsVolume = {
type: 'aws_ebs_volume',
blockType: 'resource',
@@ -117,10 +119,7 @@ const awsS3Bucket = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#object_lock_enabled',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A map of tags to assign to the resource.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#tags',
},
],
@@ -304,10 +303,7 @@ const awsEfsFileSystem = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/efs_file_system#size_in_bytes',
},
{
- name: 'tags',
- displayName: 'Tags',
- description: 'A mapping of tags to assign to the file system.',
- type: 'Object',
+ ...tags,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_file_system#tags',
},
],
@@ -337,14 +333,9 @@ const awsEfsMountTarget = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target#file_system_id',
},
{
- name: 'subnet_id',
- displayName: 'Subnet ID',
+ ...subnetId,
description: 'The ID of the subnet to add the mount target in.',
- linkRef: 'aws_subnet',
- linkType: 'Default',
- linkModel: 'defaultLink',
required: true,
- type: 'Link',
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target#subnet_id',
},
{
@@ -355,13 +346,7 @@ const awsEfsMountTarget = {
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target#ip_address',
},
{
- name: 'security_groups',
- displayName: 'Security groups',
- description: 'A list of up to 5 VPC security group IDs (that must be for the same VPC as subnet specified) in effect for the mount target.',
- linkRef: 'aws_security_group',
- linkType: 'Default',
- linkModel: 'defaultLink',
- type: 'Link',
+ ...securityGroups,
url: 'https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target#security_groups',
},
],
diff --git a/tests/resources/tf/validMain.tf b/tests/resources/tf/validMain.tf
index e816511..072bd5f 100644
--- a/tests/resources/tf/validMain.tf
+++ b/tests/resources/tf/validMain.tf
@@ -251,7 +251,7 @@ resource "aws_lb" "cms_frontend_lb" {
internal = false
load_balancer_type = "application"
security_groups = [
- aws_security_group.cms_lb_secgroup.id,
+ aws_security_group.cms_lb_secgroup.name,
]
subnets = [
aws_subnet.cms_lb_subnet_az1.id,
@@ -284,7 +284,7 @@ resource "aws_launch_configuration" "cms_launch_conf" {
]
instance_type = var.ec2_frontend_sku
security_groups = [
- aws_security_group.cms_frontend_secgroup.id,
+ aws_security_group.cms_frontend_secgroup.name,
]
}