@awsless/awsless 0.0.579 → 0.0.580

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -3963,7 +3963,7 @@ var onFailureFeature = defineFeature({
3963
3963
  }
3964
3964
  });
3965
3965
 
3966
- // src/feature/pubsub/appsync/index.ts
3966
+ // src/feature/pubsub/index.ts
3967
3967
  import { $ as $9, Group as Group9 } from "@awsless/formation";
3968
3968
  import { constantCase as constantCase5 } from "change-case";
3969
3969
 
@@ -3985,141 +3985,91 @@ var formatFullDomainName = (config2, id, subDomain) => {
3985
3985
  return domain2;
3986
3986
  };
3987
3987
 
3988
- // src/feature/pubsub/appsync/index.ts
3988
+ // src/feature/pubsub/index.ts
3989
3989
  var pubsubFeature = defineFeature({
3990
3990
  name: "pubsub",
3991
3991
  onApp(ctx) {
3992
- for (const [id, props] of Object.entries(ctx.appConfig.defaults?.pubsub ?? {})) {
3992
+ ctx.addGlobalPermission({
3993
+ actions: ["iot:Publish"],
3994
+ resources: [
3995
+ //
3996
+ `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`,
3997
+ `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/${ctx.app.name}/pubsub/*`
3998
+ ]
3999
+ });
4000
+ for (const [id, props] of Object.entries(ctx.appConfig.defaults.pubsub ?? {})) {
3993
4001
  const group = new Group9(ctx.base, "pubsub", id);
3994
- const shortName = `${ctx.app.name}--${id}`;
4002
+ const { lambda } = createLambdaFunction(group, ctx, "pubsub-authorizer", id, props.auth);
3995
4003
  const name = formatGlobalResourceName({
3996
4004
  appName: ctx.app.name,
3997
4005
  resourceType: "pubsub",
3998
4006
  resourceName: id
3999
4007
  });
4000
- const authGroup = new Group9(group, "auth", "lambda");
4001
- const { lambda: authLambda } = createLambdaFunction(authGroup, ctx, "pubsub", `${id}-auth`, {
4002
- ...props.auth,
4003
- description: `PubSub ${id} authorizer`
4004
- });
4005
- let loggingRole;
4006
- if (props.logLevel) {
4007
- loggingRole = new $9.aws.iam.Role(group, "logging-role", {
4008
- name: shortId(`${name}-logging-role`),
4009
- assumeRolePolicy: JSON.stringify({
4010
- Version: "2012-10-17",
4011
- Statement: [
4012
- {
4013
- Effect: "Allow",
4014
- Principal: {
4015
- Service: "appsync.amazonaws.com"
4016
- },
4017
- Action: "sts:AssumeRole"
4018
- }
4019
- ]
4020
- })
4021
- });
4022
- new $9.aws.iam.RolePolicyAttachment(group, "logs-policy", {
4023
- role: loggingRole.name,
4024
- policyArn: "arn:aws:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
4025
- });
4026
- }
4027
- const api = new $9.aws.appsync.Api(group, "api", {
4028
- name: shortName,
4029
- eventConfig: [
4030
- {
4031
- connectionAuthMode: [{ authType: "AWS_IAM" }, { authType: "AWS_LAMBDA" }],
4032
- authProvider: [
4033
- {
4034
- authType: "AWS_LAMBDA",
4035
- lambdaAuthorizerConfig: [
4036
- {
4037
- authorizerUri: authLambda.arn,
4038
- authorizerResultTtlInSeconds: 300
4039
- }
4040
- ]
4041
- },
4042
- {
4043
- authType: "AWS_IAM"
4044
- }
4045
- ],
4046
- defaultPublishAuthMode: [
4047
- {
4048
- authType: "AWS_IAM"
4049
- }
4050
- ],
4051
- defaultSubscribeAuthMode: [
4052
- {
4053
- authType: "AWS_LAMBDA"
4054
- },
4055
- {
4056
- authType: "AWS_IAM"
4057
- }
4058
- ],
4059
- logConfig: props.logLevel ? [
4060
- {
4061
- logLevel: props.logLevel.toUpperCase(),
4062
- cloudwatchLogsRoleArn: loggingRole.arn
4063
- }
4064
- ] : void 0
4065
- }
4066
- ]
4008
+ const authorizer = new $9.aws.iot.Authorizer(group, "authorizer", {
4009
+ name,
4010
+ authorizerFunctionArn: lambda.arn,
4011
+ status: "ACTIVE",
4012
+ signingDisabled: true,
4013
+ enableCachingForHttp: false
4067
4014
  });
4068
- const namespaces = props.namespaces ?? ["default"];
4069
- for (const namespace of namespaces) {
4070
- new $9.aws.appsync.ChannelNamespace(group, `namespace-${namespace}`, {
4071
- name: namespace,
4072
- apiId: api.apiId
4073
- });
4074
- }
4075
- new $9.aws.lambda.Permission(group, "auth-permission", {
4015
+ new $9.aws.lambda.Permission(group, "permission", {
4016
+ functionName: lambda.functionName,
4076
4017
  action: "lambda:InvokeFunction",
4077
- principal: "appsync.amazonaws.com",
4078
- functionName: authLambda.functionName,
4079
- sourceArn: api.apiArn
4018
+ principal: "iot.amazonaws.com",
4019
+ sourceArn: authorizer.arn
4020
+ });
4021
+ ctx.bind(`PUBSUB_${constantCase5(id)}_AUTHORIZER`, name);
4022
+ const endpoint = $9.aws.iot.getEndpoint(group, "endpoint", {
4023
+ endpointType: "iot:Data-ATS"
4080
4024
  });
4081
4025
  if (props.domain) {
4082
4026
  const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
4083
- const zoneId = ctx.shared.entry("domain", `zone-id`, props.domain);
4084
- const certificateArn = ctx.shared.entry("domain", `certificate-arn`, props.domain);
4085
- const apiDomain = new $9.aws.appsync.DomainName(group, "domain", {
4027
+ new $9.aws.iot.DomainConfiguration(group, "domain", {
4028
+ name,
4086
4029
  domainName,
4087
- certificateArn
4088
- });
4089
- new $9.aws.appsync.DomainNameApiAssociation(group, "domain-association", {
4090
- apiId: api.apiArn,
4091
- domainName: apiDomain.domainName
4030
+ serverCertificateArns: [ctx.shared.entry("domain", `certificate-arn`, props.domain)],
4031
+ authorizerConfig: {
4032
+ defaultAuthorizerName: authorizer.name
4033
+ }
4034
+ // validationCertificate: ctx.shared.get(`global-certificate-${props.domain}-arn`),
4092
4035
  });
4093
4036
  new $9.aws.route53.Record(group, "record", {
4094
- zoneId,
4095
- type: "CNAME",
4037
+ zoneId: ctx.shared.entry("domain", `zone-id`, props.domain),
4096
4038
  name: domainName,
4097
- records: [apiDomain.appsyncDomainName],
4098
- ttl: 300
4039
+ type: "CNAME",
4040
+ records: [endpoint.endpointAddress]
4099
4041
  });
4100
- ctx.bind(`PUBSUB_${constantCase5(id)}_ENDPOINT`, `${domainName}/event`);
4101
- ctx.bind(`PUBSUB_${constantCase5(id)}_REALTIME_ENDPOINT`, `${domainName}/event/realtime`);
4042
+ ctx.bind(`PUBSUB_${constantCase5(id)}_ENDPOINT`, domainName);
4102
4043
  } else {
4103
- ctx.bind(
4104
- `PUBSUB_${constantCase5(id)}_ENDPOINT`,
4105
- api.dns.pipe((dns) => dns.HTTP)
4106
- );
4107
- ctx.bind(
4108
- `PUBSUB_${constantCase5(id)}_REALTIME_ENDPOINT`,
4109
- api.dns.pipe((dns) => dns.REALTIME)
4110
- );
4044
+ ctx.bind(`PUBSUB_${constantCase5(id)}_ENDPOINT`, endpoint.endpointAddress);
4111
4045
  }
4112
4046
  }
4047
+ },
4048
+ onStack(ctx) {
4049
+ for (const [id, props] of Object.entries(ctx.stackConfig.pubsub ?? {})) {
4050
+ const group = new Group9(ctx.stack, "pubsub", id);
4051
+ const { lambda } = createAsyncLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
4052
+ const name = formatLocalResourceName({
4053
+ appName: ctx.app.name,
4054
+ stackName: ctx.stack.name,
4055
+ resourceType: "pubsub",
4056
+ resourceName: id
4057
+ });
4058
+ const topic = new $9.aws.iot.TopicRule(group, "rule", {
4059
+ name: name.replaceAll("-", "_"),
4060
+ enabled: true,
4061
+ sql: props.sql,
4062
+ sqlVersion: props.sqlVersion,
4063
+ lambda: [{ functionArn: lambda.arn }]
4064
+ });
4065
+ new $9.aws.lambda.Permission(group, "permission", {
4066
+ action: "lambda:InvokeFunction",
4067
+ principal: "iot.amazonaws.com",
4068
+ functionName: lambda.functionName,
4069
+ sourceArn: topic.arn
4070
+ });
4071
+ }
4113
4072
  }
4114
- // Note: The onStack method would handle channel namespaces and subscriptions
4115
- // but is commented out for now as it needs to be refactored for AppSync Event API
4116
- // onStack(ctx) {
4117
- // // Channel namespaces and event handlers would be configured here
4118
- // // This would include:
4119
- // // 1. Creating channel namespaces with their own auth modes (overriding defaults)
4120
- // // 2. Setting up event handlers (Lambda functions) for specific channels
4121
- // // 3. Configuring event filtering and routing rules
4122
- // },
4123
4073
  });
4124
4074
 
4125
4075
  // src/feature/queue/index.ts
@@ -7166,9 +7116,10 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
7166
7116
  // 'awslogs-group': `/aws/ecs/${name}`,
7167
7117
  "awslogs-group": `/aws/lambda/${name}`,
7168
7118
  "awslogs-region": ctx.appConfig.region,
7169
- "awslogs-stream-prefix": "ecs"
7170
- // mode: 'non-blocking',
7171
- // 'max-buffer-size': '1m',
7119
+ "awslogs-stream-prefix": "ecs",
7120
+ mode: "non-blocking"
7121
+ // 'awslogs-multiline-pattern': '',
7122
+ // 'max-buffer-size': '100m',
7172
7123
  }
7173
7124
  }
7174
7125
  },
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.579",
3
+ "version": "0.0.580",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -35,11 +35,11 @@
35
35
  "peerDependencies": {
36
36
  "@awsless/big-float": "^0.1.4",
37
37
  "@awsless/cloudwatch": "^0.0.1",
38
+ "@awsless/dynamodb": "^0.2.10",
38
39
  "@awsless/duration": "^0.0.3",
39
40
  "@awsless/clui": "^0.0.7",
40
41
  "@awsless/iot": "^0.0.3",
41
42
  "@awsless/json": "^0.0.10",
42
- "@awsless/dynamodb": "^0.2.10",
43
43
  "@awsless/lambda": "^0.0.33",
44
44
  "@awsless/mqtt": "^0.0.2",
45
45
  "@awsless/open-search": "^0.0.21",
@@ -135,13 +135,13 @@
135
135
  "zod": "^3.24.2",
136
136
  "zod-to-json-schema": "^3.24.3",
137
137
  "@awsless/big-float": "^0.1.4",
138
- "@awsless/cloudwatch": "^0.0.1",
139
138
  "@awsless/clui": "^0.0.7",
139
+ "@awsless/cloudwatch": "^0.0.1",
140
+ "@awsless/duration": "^0.0.3",
140
141
  "@awsless/formation": "^0.0.80",
141
142
  "@awsless/graphql": "^0.0.9",
142
- "@awsless/duration": "^0.0.3",
143
- "@awsless/json": "^0.0.10",
144
143
  "@awsless/scheduler": "^0.0.4",
144
+ "@awsless/json": "^0.0.10",
145
145
  "@awsless/size": "^0.0.2",
146
146
  "@awsless/validate": "^0.0.19",
147
147
  "@awsless/ts-file-cache": "^0.0.12"