and AWS Intellectual Property License()

in packages/aws-rfdk/lib/deadline/lib/thinkbox-docker-images.ts [145:243]


and AWS Intellectual Property License (https://aws.amazon.com/legal/aws-ip-license-terms/). You acknowledge that Deadline
is AWS Content as defined in those Agreements.

Please set the userAwsCustomerAgreementAndIpLicenseAcceptance property to
USER_ACCEPTS_AWS_CUSTOMER_AGREEMENT_AND_IP_LICENSE to signify your acceptance of these terms.
`;

  /**
   * A {@link DockerImageAsset} that can be used to build Thinkbox's Deadline RCS Docker Recipe into a
   * container image that can be deployed in CDK.
   *
   * @param scope The parent scope
   * @param id The construct ID
   */
  public readonly remoteConnectionServer: ContainerImage;

  /**
   * A {@link DockerImageAsset} that can be used to build Thinkbox's Deadline License Forwarder Docker Recipe into a
   * container image that can be deployed in CDK.
   *
   * @param scope The parent scope
   * @param id The construct ID
   */
  public readonly licenseForwarder: ContainerImage;

  /**
   * The version of Deadline installed in the container images
   */
  private readonly version?: IVersion;

  /**
   * The base URI for AWS Thinkbox published Deadline ECR images.
   */
  private readonly ecrBaseURI: string;

  /**
   * Whether the user has accepted the terms of the AWS Content Agreement and AWS Intellectual Property License.
   */
  private readonly userAwsCustomerAgreementAndIpLicenseAcceptance: AwsCustomerAgreementAndIpLicenseAcceptance;

  constructor(scope: Construct, id: string, props: ThinkboxDockerImagesProps) {
    super(scope, id);

    this.userAwsCustomerAgreementAndIpLicenseAcceptance = props.userAwsCustomerAgreementAndIpLicenseAcceptance;
    this.version = props?.version;

    const lambdaCode = Code.fromAsset(path.join(__dirname, '..', '..', 'lambdas', 'nodejs'));

    const lambdaFunc = new SingletonFunction(this, 'VersionProviderFunction', {
      uuid: '08553416-1fc9-4be9-a818-609a31ae1b5b',
      description: 'Used by the ThinkboxDockerImages construct to look up the ECR repositories where AWS Thinkbox publishes Deadline container images.',
      code: lambdaCode,
      runtime: Runtime.NODEJS_18_X,
      handler: 'ecr-provider.handler',
      timeout: Duration.seconds(30),
      logRetention: RetentionDays.ONE_WEEK,
    });

    const ecrProvider = new CustomResource(this, 'ThinkboxEcrProvider', {
      serviceToken: lambdaFunc.functionArn,
      properties: {
        // create a random string that will force the Lambda to "update" on each deployment. Changes to its output will
        // be propagated to any CloudFormation resource providers that reference the output ARN
        ForceRun: this.forceRun(),
      },
      resourceType: 'Custom::RFDK_EcrProvider',
    });

    this.node.defaultChild = ecrProvider;

    this.ecrBaseURI = ecrProvider.getAtt('EcrURIPrefix').toString();

    this.remoteConnectionServer = this.ecrImageForRecipe(ThinkboxManagedDeadlineDockerRecipes.REMOTE_CONNECTION_SERVER);
    this.licenseForwarder = this.ecrImageForRecipe(ThinkboxManagedDeadlineDockerRecipes.LICENSE_FORWARDER);

    const thisConstruct = this;
    this.node.addValidation({
      validate(): string[] {
        const errors: string[] = [];

        // Users must accept the AWS Customer Agreement and AWS Intellectual Property License to use the container images
        if (thisConstruct.userAwsCustomerAgreementAndIpLicenseAcceptance !==
            AwsCustomerAgreementAndIpLicenseAcceptance.USER_ACCEPTS_AWS_CUSTOMER_AGREEMENT_AND_IP_LICENSE) {
          errors.push(ThinkboxDockerImages.AWS_CONTENT_NOTICE);
        }

        // Using the output of VersionQuery across stacks can cause issues. CloudFormation stack outputs cannot change if
        // a resource in another stack is referencing it.
        if (thisConstruct.version instanceof VersionQuery) {
          const versionStack = Stack.of(thisConstruct.version);
          const thisStack = Stack.of(thisConstruct);
          if (versionStack != thisStack) {
            errors.push('A VersionQuery can not be supplied from a different stack');
          }
        }
        return errors;
      },
    });
  }