/// <summary> /// Parse an Arn to extract information on S3 outpost access point /// and if it is not found or properly formatted, throw an exception /// </summary> /// <param name="arn"></param> /// <returns></returns> public static S3OutpostResource ParseOutpost(this Arn arn) { if (string.IsNullOrEmpty(arn.Resource)) { throw new AmazonClientException("Arn Resource can not be null"); } if (!IsOutpostArn(arn)) { throw new AmazonClientException($"Arn Resource: {arn.Resource} does not resemble an outpost access point"); } var outpostAccessPointString = arn.Resource; var separators = new char[] { '/', ':' }; var parts = outpostAccessPointString.Split(separators, 5); if (parts.Length < 4 || !String.Equals(parts[2], "accesspoint")) { throw new AmazonClientException($"Invalid ARN: {arn.ToString()}, outpost resource format is incorrect"); } var outpost = new S3OutpostResource(arn); outpost.OutpostId = parts[1]; outpost.AccessPointName = parts[3]; if (parts.Length > 4) { outpost.Key = parts[4]; } return(new S3OutpostResource(arn) { OutpostId = parts[1], AccessPointName = parts[3], Key = parts.Length > 4 ? parts[4] : null }); }
/// <summary> /// Validates S3ObjectLambda Access Points. /// </summary> private static void ValidateS3ObjectLambdaAccessPoint(Arn arn, AmazonS3Config s3Config, RegionEndpoint region) { var arnString = arn.ToString(); if (!arn.HasValidAccountId()) { throw new AmazonAccountIdException(); } foreach (var ch in arnString) { if (!char.IsLetterOrDigit(ch) && ch != ':' && ch != '/' && ch != '-') { throw new AmazonClientException("Invalid Arn. S3ObjectLambda arns can only contain alphanumeric characters, :, / and -"); } } if (arn.Resource.Split(':').Length > 2) { throw new AmazonClientException("Invalid ARN, Access Point ARN contains sub resources"); } if (s3Config.UseAccelerateEndpoint) { throw new AmazonClientException("Invalid configuration S3ObjectLambda access points do not support accelerate"); } if (s3Config.UseDualstackEndpoint) { throw new AmazonClientException("Invalid configuration S3ObjectLambda access points do not support dualstack"); } if (HasValidFips(arn, s3Config, region)) // will throw on invalid configs { return; } if (string.IsNullOrEmpty(arn.AccountId)) { throw new AmazonClientException("Account ID is missing in S3ObjectLambda access point ARN"); } if (string.IsNullOrEmpty(arn.Region)) { throw new AmazonClientException("AWS region is missing in S3ObjectLambda access point ARN"); } if (!string.Equals(region.PartitionName, arn.Partition)) { throw new AmazonClientException("Invalid configuration, cross partition S3ObjectLambda access point ARN"); } if (!s3Config.UseArnRegion && !string.Equals(arn.Region, region.SystemName, StringComparison.Ordinal)) { throw new AmazonClientException("Invalid configuration, cross region S3ObjectLambda access point ARN"); } }
public QueueConfig(Arn arn) : base(arn) { Queue = arn.ToString(); }
public LambdaConfig(Arn arn) : base(arn) { Lambda = arn.ToString(); }
public TopicConfig(Arn arn) : base(arn) { Topic = arn.ToString(); }