diff --git a/aws/aws_blueprints_template/main.tf b/aws/aws_blueprints_template/main.tf index 2ce3a6a..098a6b9 100644 --- a/aws/aws_blueprints_template/main.tf +++ b/aws/aws_blueprints_template/main.tf @@ -92,4 +92,16 @@ module "port_eks_cluster" { source = "../eks_cluster" count = contains(var.resources, "eks_cluster") ? 1 : 0 depends_on = [port-labs_blueprint.region] +} + +module "port_elasticache_cluster" { + source = "../elasticache_cluster" + count = contains(var.resources, "elasticache_cluster") ? 1 : 0 + depends_on = [port-labs_blueprint.region] +} + +module "port_ecr_repository" { + source = "../ecr_repository" + count = contains(var.resources, "ecr_repository") ? 1 : 0 + depends_on = [port-labs_blueprint.region] } \ No newline at end of file diff --git a/aws/ecr_repository/blueprint.tf b/aws/ecr_repository/blueprint.tf new file mode 100644 index 0000000..0b9411c --- /dev/null +++ b/aws/ecr_repository/blueprint.tf @@ -0,0 +1,71 @@ +terraform { + required_providers { + port-labs = { + source = "port-labs/port-labs" + version = "0.10.4" + } + } +} + +resource "port-labs_blueprint" "ecr_repository" { + title = "ECR Repository" + icon = "Service" + identifier = "ecr_repository" + + properties { + identifier = "link" + type = "string" + format = "url" + title = "Link" + } + + properties { + identifier = "imageTagMutability" + type = "string" + title = "Image Tag Mutability" + } + + properties { + identifier = "repositoryArn" + type = "string" + title = "Repository ARN" + } + + properties { + identifier = "repositoryUri" + type = "string" + title = "Repository URI" + } + + properties { + identifier = "scanningConfiguration" + type = "object" + title = "Scanning Configuration" + } + + properties { + identifier = "encryptionConfiguration" + type = "object" + title = "Encryption Configuration" + } + + properties { + identifier = "lifecyclePolicy" + type = "object" + title = "Lifecycle Policy" + } + + properties { + identifier = "tags" + type = "array" + title = "Tags" + } + + relations { + target = "region" + title = "Region" + identifier = "region" + many = false + required = false + } +} diff --git a/aws/ecr_repository/config.json b/aws/ecr_repository/config.json new file mode 100644 index 0000000..00b2ee8 --- /dev/null +++ b/aws/ecr_repository/config.json @@ -0,0 +1,27 @@ +{ + "kind":"AWS::ECR::Repository", + "port":{ + "entity":{ + "mappings":[ + { + "identifier":".RepositoryName", + "title":".RepositoryName", + "blueprint":"ecr_repository", + "properties":{ + "imageTagMutability":".ImageTagMutability", + "scanningConfiguration":".ImageScanningConfiguration", + "repositoryArn":".Arn", + "link":"\"https://console.aws.amazon.com/go/view?arn=\" + .Arn", + "repositoryUri":".RepositoryUri", + "encryptionConfiguration":".EncryptionConfiguration", + "lifecyclePolicy":".LifecyclePolicy", + "tags":".Tags" + }, + "relations":{ + "region":".Arn | split(\":\") | .[3]" + } + } + ] + } + } + } \ No newline at end of file diff --git a/aws/ecr_repository/event_rule.yaml b/aws/ecr_repository/event_rule.yaml new file mode 100644 index 0000000..83dc0aa --- /dev/null +++ b/aws/ecr_repository/event_rule.yaml @@ -0,0 +1,70 @@ +ECRRepositoryEventRule: + Type: AWS::Events::Rule + Properties: + EventBusName: default + EventPattern: + detail-type: + - AWS API Call via CloudTrail + source: + - aws.ecr + detail: + eventSource: + - ecr.amazonaws.com + eventName: + - prefix: CreateRepository + - prefix: DeleteRepository + - prefix: DeleteLifecyclePolicy + - prefix: PutLifecyclePolicy + Name: port-aws-exporter-sync-ecr-trails + State: ENABLED + Targets: + - Id: PortAWSExporterEventsQueue + Arn: + Fn::ImportValue: + Fn::Sub: ${PortAWSExporterStackName}-EventsQueueARN + InputTransformer: + InputPathsMap: + awsRegion: $.detail.awsRegion + eventName: $.detail.eventName + repositoryName: $.detail.requestParameters.repositoryName + InputTemplate: >- + { + "resource_type": "AWS::ECR::Repository", + "region": "\"\"", + "identifier": "\"\"", + "action": "if \"\" | startswith(\"DeleteRepository\") then \"delete\" else \"upsert\" end" + } +ECRRepositoryTagRule: + Type: AWS::Events::Rule + Properties: + EventBusName: default + EventPattern: + source: + - aws.ecr + detail-type: + - AWS API Call via CloudTrail + detail: + eventSource: + - ecr.amazonaws.com + eventName: + - prefix: TagResource + - prefix: UntagResource + Name: port-aws-exporter-sync-ecr-tags-trails + State: ENABLED + Targets: + - Id: PortAWSExporterEventsQueue + Arn: + Fn::ImportValue: + Fn::Sub: ${PortAWSExporterStackName}-EventsQueueARN + InputTransformer: + InputPathsMap: + awsRegion: $.detail.awsRegion + eventName: $.detail.eventName + resourceArn: $.detail.requestParameters.resourceArn + InputTemplate: |- + { + "resource_type": "AWS::ECR::Repository", + "region": "\"\"", + "identifier": "\"\" | split(\"/\") | .[-1]", + "action": "\"upsert\"" + } \ No newline at end of file diff --git a/aws/ecr_repository/policy.json b/aws/ecr_repository/policy.json new file mode 100644 index 0000000..74095df --- /dev/null +++ b/aws/ecr_repository/policy.json @@ -0,0 +1,6 @@ +[ + "ecr:DescribeRepositories", + "ecr:GetLifecyclePolicy", + "ecr:GetRepositoryPolicy", + "ecr:ListTagsForResource" + ] \ No newline at end of file diff --git a/aws/elasticache_cluster/blueprint.tf b/aws/elasticache_cluster/blueprint.tf new file mode 100644 index 0000000..ef38be5 --- /dev/null +++ b/aws/elasticache_cluster/blueprint.tf @@ -0,0 +1,109 @@ +terraform { + required_providers { + port-labs = { + source = "port-labs/port-labs" + version = "0.10.4" + } + } +} + +resource "port-labs_blueprint" "elasticache_cluster" { + title = "Elasticache Cluster" + icon = "AWS" + identifier = "elasticache_cluster" + + properties { + identifier = "status" + type = "string" + title = "Status" + } + + properties { + identifier = "engine" + type = "string" + title = "Engine" + } + + properties { + identifier = "engineVersion" + type = "string" + title = "Engine Version" + } + + properties { + identifier = "preferredAvailabilityZone" + type = "string" + title = "Preferred Availability Zone" + } + + properties { + identifier = "createdDate" + type = "string" + format = "date-time" + title = "Created Date" + } + + properties { + identifier = "arn" + type = "string" + title = "ARN" + } + + properties { + identifier = "transitEncryptionEnabled" + type = "boolean" + title = "Transit Encryption Enabled" + } + + properties { + identifier = "atRestEncryptionEnabled" + type = "boolean" + title = "At Rest Encryption Enabled" + } + + properties { + identifier = "nodeType" + type = "string" + title = "Node Type" + } + + properties { + identifier = "link" + type = "string" + title = "Link" + format = "url" + } + + properties { + identifier = "subnetGroupName" + type = "string" + title = "Subnet Group Name" + } + + properties { + identifier = "numNodes" + type = "number" + title = "Number of Nodes" + } + + properties { + identifier = "securityGroups" + type = "array" + title = "Security Groups" + } + + properties { + identifier = "tags" + type = "array" + title = "Tags" + } + + relations { + target = "region" + title = "Region" + identifier = "region" + many = false + required = false + } + +} diff --git a/aws/elasticache_cluster/config.json b/aws/elasticache_cluster/config.json new file mode 100644 index 0000000..3a5dfe7 --- /dev/null +++ b/aws/elasticache_cluster/config.json @@ -0,0 +1,33 @@ +{ + "kind":"AWS::ElastiCache::CacheCluster", + "port":{ + "entity":{ + "mappings":[ + { + "identifier":".CacheClusterId", + "title":".CacheClusterId", + "blueprint":"elasticache_cluster", + "properties":{ + "engine": ".Engine", + "engineVersion": ".EngineVersion", + "preferredAvailabilityZone": ".PreferredAvailabilityZone", + "createdDate": ".CacheClusterCreateTime", + "arn": ".ARN", + "transitEncryptionEnabled": ".TransitEncryptionEnabled", + "atRestEncryptionEnabled": ".AtRestEncryptionEnabled", + "link": "\"https://console.aws.amazon.com/go/view?arn=\" + .ARN", + "nodeType": ".CacheNodeType", + "status": ".CacheClusterStatus", + "tags": ".Tags", + "numNodes": ".NumCacheNodes", + "securityGroups": ".CacheSecurityGroups", + "subnetGroupName": ".CacheSubnetGroupName" + }, + "relations":{ + "region":".ARN | split(\":\") | .[3]" + } + } + ] + } + } + } \ No newline at end of file diff --git a/aws/elasticache_cluster/event_rule.yaml b/aws/elasticache_cluster/event_rule.yaml new file mode 100644 index 0000000..34181df --- /dev/null +++ b/aws/elasticache_cluster/event_rule.yaml @@ -0,0 +1,69 @@ +ElasticacheEventRule: + Type: AWS::Events::Rule + Properties: + EventBusName: default + EventPattern: + detail-type: + - AWS API Call via CloudTrail + source: + - aws.elasticache + detail: + eventSource: + - elasticache.amazonaws.com + eventName: + - prefix: CreateCacheCluster + - prefix: DeleteCacheCluster + - prefix: ModifyCacheCluster + Name: port-aws-exporter-sync-cache-cluster-trails + State: ENABLED + Targets: + - Id: PortAWSExporterEventsQueue + Arn: + Fn::ImportValue: + Fn::Sub: ${PortAWSExporterStackName}-EventsQueueARN + InputTransformer: + InputPathsMap: + awsRegion: $.detail.awsRegion + eventName: $.detail.eventName + cacheName: $.detail.responseElements.cacheClusterId + InputTemplate: >- + { + "resource_type": "AWS::ElastiCache::CacheCluster", + "region": "\"\"", + "identifier": "\"\"", + "action": "if \"\" | startswith(\"DeleteCacheCluster\") then \"delete\" else \"upsert\" end" + } +ElasticacheTagRule: + Type: AWS::Events::Rule + Properties: + EventBusName: default + EventPattern: + source: + - aws.elasticache + detail-type: + - AWS API Call via CloudTrail + detail: + eventSource: + - elasticache.amazonaws.com + eventName: + - prefix: AddTagsToResource + - prefix: RemoveTagsFromResource + Name: port-aws-exporter-sync-cache-cluster-tags-trails + State: ENABLED + Targets: + - Id: PortAWSExporterEventsQueue + Arn: + Fn::ImportValue: + Fn::Sub: ${PortAWSExporterStackName}-EventsQueueARN + InputTransformer: + InputPathsMap: + awsRegion: $.detail.awsRegion + eventName: $.detail.eventName + resourceArn: $.detail.requestParameters.resourceName + InputTemplate: |- + { + "resource_type": "AWS::ElastiCache::CacheCluster", + "region": "\"\"", + "identifier": "\"\" | split(\":\") | .[-1]", + "action": "\"upsert\"" + } \ No newline at end of file diff --git a/aws/elasticache_cluster/policy.json b/aws/elasticache_cluster/policy.json new file mode 100644 index 0000000..7dd3c8b --- /dev/null +++ b/aws/elasticache_cluster/policy.json @@ -0,0 +1,4 @@ +[ + "elasticache:DescribeCacheClusters", + "elasticache:ListTagsForResource" +] \ No newline at end of file