Skip to content

Commit a51e670

Browse files
committed
feat: Add restrictionType to Cloudfront, geoRestriction
1 parent d79a230 commit a51e670

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/services/cloudfront/format.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Origin,
55
} from 'aws-sdk/clients/cloudfront'
66
import cuid from 'cuid'
7-
import isEmpty from 'lodash/isEmpty'
87

98
import t from '../../properties/translations'
109
import { formatTagsFromMap } from '../../utils/format'
@@ -118,7 +117,7 @@ export default ({
118117
CallerReference: callerReference,
119118
DefaultRootObject: defaultRootObject,
120119
HttpVersion: httpVersion,
121-
Restrictions: { GeoRestriction: { Items: geoRestrictions = [] } } = {
120+
Restrictions: { GeoRestriction: { Items: locations = [], RestrictionType: restrictionType = ''} } = {
122121
GeoRestriction: { RestrictionType: '', Items: [], Quantity: 0 },
123122
},
124123
Logging: logging,
@@ -237,9 +236,10 @@ export default ({
237236
domainName,
238237
enabled: enabled ? t.yes : t.no,
239238
etag,
240-
geoRestrictions: !isEmpty(geoRestrictions)
241-
? geoRestrictions.join(',')
242-
: 'none',
239+
geoRestriction: {
240+
restrictionType,
241+
locations,
242+
},
243243
httpVersion,
244244
ipv6Enabled: isIpv6Enabled ? t.yes : t.no,
245245
lastModified: lastModified.toISOString(),

src/services/cloudfront/schema.graphql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type awsCloudfront @key(fields: "id") {
1313
ipv6Enabled: String @search(by: [hash])
1414
defaultRootObject: String @search(by: [hash])
1515
webAclId: String @search(by: [hash])
16-
geoRestrictions: String @search(by: [hash, regexp])
16+
geoRestriction: awsCloudfrontGeoRestriction
1717
customErrorResponses: [awsCloudfrontCustomErrorResponse]
1818
defaultCacheBehavior: awsCloudfrontCacheBehavior
1919
orderedCacheBehaviors: [awsCloudfrontCacheBehavior]
@@ -96,4 +96,9 @@ type awsCloudfrontLoggingConfig {
9696
includeCookies: Boolean @search
9797
bucket: String @search(by: [hash, regexp])
9898
prefix: String @search(by: [hash, regexp])
99+
}
100+
101+
type awsCloudfrontGeoRestriction {
102+
restrictionType: String @search(by: [hash, regexp])
103+
locations: [String] @search(by: [hash, regexp])
99104
}

src/types/generated.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ export type AwsCloudfront = {
780780
elb?: Maybe<Array<Maybe<AwsElb>>>;
781781
enabled?: Maybe<Scalars['String']>;
782782
etag?: Maybe<Scalars['String']>;
783-
geoRestrictions?: Maybe<Scalars['String']>;
783+
geoRestriction?: Maybe<AwsCloudfrontGeoRestriction>;
784784
httpVersion?: Maybe<Scalars['String']>;
785785
id: Scalars['String'];
786786
ipv6Enabled?: Maybe<Scalars['String']>;
@@ -829,6 +829,11 @@ export type AwsCloudfrontCustomOriginConfig = {
829829
originSslProtocols?: Maybe<AwsCloudfrontOriginSslProtocols>;
830830
};
831831

832+
export type AwsCloudfrontGeoRestriction = {
833+
locations?: Maybe<Array<Maybe<Scalars['String']>>>;
834+
restrictionType?: Maybe<Scalars['String']>;
835+
};
836+
832837
export type AwsCloudfrontLoggingConfig = {
833838
bucket?: Maybe<Scalars['String']>;
834839
enabled?: Maybe<Scalars['Boolean']>;

0 commit comments

Comments
 (0)